-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
GH-103319: Fix inspect.getsourcelines()
to return 1-based line numbers
#103226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
GH-103319: Fix inspect.getsourcelines()
to return 1-based line numbers
#103226
Conversation
@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
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