-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
gh-143299: Doc: Clarify inspect.getsource behavior regarding shared lines #143301
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?
Conversation
| @@ -0,0 +1 @@ | |||
| Doc: Clarify inspect.getsource behavior regarding shared lines (GH-143299) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we only update docs, we don't needs a NEWS entry usually. Also, we don't mention the GH issue either (I'd suggest having a look at the contents of Misc/NEWS.d/next to see how other NEWS entries are formatted)
af494f9 to
177a040
Compare
| A :exc:`TypeError` is raised if the object is a built-in module, class, or | ||
| function. | ||
|
|
||
| .. note:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note is too loгd. This can be an ordinary paragraph. AFAIK classes and normal funtions always take the whole line, so this not is only related to lambdas and generator expressions (generator expressions themselves are not supported, but code, frames and tracebacks do). It would be better to mention them explicitly, so the user that searches the sources of a class or normal function should not worry.
This should be repeated for getsourcelines().
Fixing the ambiguity where getsource returns full lines for lambdas/comprehensions.
Closes gh-143299
📚 Documentation preview 📚: https://cpython-previews--143301.org.readthedocs.build/