gh-143299: Doc: Clarify inspect.getsource behavior regarding shared lines#143301
Open
a12k wants to merge 3 commits intopython:mainfrom
Open
gh-143299: Doc: Clarify inspect.getsource behavior regarding shared lines#143301a12k wants to merge 3 commits intopython:mainfrom
a12k wants to merge 3 commits intopython:mainfrom
Conversation
picnixz
reviewed
Dec 30, 2025
| @@ -0,0 +1 @@ | |||
| Doc: Clarify inspect.getsource behavior regarding shared lines (GH-143299) | |||
Member
There was a problem hiding this comment.
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:: |
Member
There was a problem hiding this comment.
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().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixing the ambiguity where getsource returns full lines for lambdas/comprehensions.
Closes gh-143299
📚 Documentation preview 📚: https://cpython-previews--143301.org.readthedocs.build/