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 intopython:mainfrom
inspect.getsourcelines() to return 1-based line numbers#103226Conversation
|
@iritkatriel Could you please take a look, as this is a follow-up to #101674 you already reviewed? |
|
1-based does seem more reasonable. But if we are fixing this, how about the code in |
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. |
|
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 |
|
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 . |
|
@iritkatriel Thank you for the quick response. That sounds reasonable. I can create a separate issue regarding @gaogaotiantian Thanks for pointing |
|
@iritkatriel @gaogaotiantian I have opened a new issue regarding |
inspect.getsourcelines() to return 1-based line numbersinspect.getsourcelines() to return 1-based line numbers
|
A solution may be to change the documentation, rather than the result, so that existing code does not break. |
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