Skip to content

Commit 202e16e

Browse files
gh-98239: Document that inspect.getsource() can raise TypeError (GH-101689)
(cherry picked from commit b613208) Co-authored-by: Nikita Sobolev <[email protected]>
1 parent e2924c0 commit 202e16e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Doc/library/inspect.rst

+4
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,8 @@ Retrieving source code
553553
object and the line number indicates where in the original source file the first
554554
line of code was found. An :exc:`OSError` is raised if the source code cannot
555555
be retrieved.
556+
A :exc:`TypeError` is raised if the object is a built-in module, class, or
557+
function.
556558

557559
.. versionchanged:: 3.3
558560
:exc:`OSError` is raised instead of :exc:`IOError`, now an alias of the
@@ -565,6 +567,8 @@ Retrieving source code
565567
class, method, function, traceback, frame, or code object. The source code is
566568
returned as a single string. An :exc:`OSError` is raised if the source code
567569
cannot be retrieved.
570+
A :exc:`TypeError` is raised if the object is a built-in module, class, or
571+
function.
568572

569573
.. versionchanged:: 3.3
570574
:exc:`OSError` is raised instead of :exc:`IOError`, now an alias of the

0 commit comments

Comments
 (0)