Uh oh!
There was an error while loading. Please reload this page.
GH-103319: Fix inspect.getsourcelines() to return 1-based line numbers - #103226
GH-103319: Fix inspect.getsourcelines() to return 1-based line numbers#103226artemmukhin wants to merge 2 commits into
inspect.getsourcelines() to return 1-based line numbers#103226Conversation
artemmukhin
commented
Apr 3, 2023
@iritkatriel Could you please take a look, as this is a follow-up to #101674 you already reviewed? |
gaogaotiantian
commented
Apr 3, 2023
1-based does seem more reasonable. But if we are fixing this, how about the code in |
iritkatriel
commented
Apr 3, 2023
The bug in pdb that you describe in the issue may be new, but you are changing behaviour of inspect in the PR. Question is whether this is a bug in inspect. |
gaogaotiantian
commented
Apr 3, 2023
The doc of I would think this as a bug, but it's true that this is a breaking behavior. If we kept it as it is in |
iritkatriel
commented
Apr 4, 2023
If there's a fix in pdb that you can do so we don't release a new bug there, then let's do it. Changing inspect probably would require more discussion. FYI @Yhg1s . |
artemmukhin
commented
Apr 4, 2023
@iritkatriel Thank you for the quick response. That sounds reasonable. I can create a separate issue regarding @gaogaotiantian Thanks for pointing |
artemmukhin
commented
Apr 6, 2023
@iritkatriel@gaogaotiantian I have opened a new issue regarding |
inspect.getsourcelines() to return 1-based line numbersinspect.getsourcelines() to return 1-based line numbersGeorge-Ogden
commented
Jul 20, 2025
A solution may be to change the documentation, rather than the result, so that existing code does not break. |
This PR is stale because it has been open for 30 days with no activity. |
The problem is described in GH-103225.
I did not find any other usages of a line number returned by
inspect.getsourcelines()except forpdb. However, I am not sure how many external usages ofinspect.getsourcelines()already rely on 0-based line numbers for modules.inspect.{getsourcelines, findsource}return 0 as the starting line number for modules #103319