Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Doc/library/inspect.rst
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,11 @@ Retrieving source code
A :exc:`TypeError` is raised if the object is a built-in module, class, or
function.

.. note::
Copy link
Member

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().

This function returns the lines of source code where the object is
defined, including indentation. It always returns full lines and does not
strip other code that may appear on the same line.

.. versionchanged:: 3.3
:exc:`OSError` is raised instead of :exc:`IOError`, now an alias of the
former.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Doc: Clarify inspect.getsource behavior regarding shared lines (GH-143299)
Copy link
Member

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)

Loading