Skip to content

Commit 52b3481

Browse files
committed
pythongh-98239: Document that inspect.getsource() can raise TypeError
1 parent a9f0144 commit 52b3481

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Doc/library/inspect.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,9 @@ Retrieving source code
573573
object. The source code is returned as a list of the lines corresponding to the
574574
object and the line number indicates where in the original source file the first
575575
line of code was found. An :exc:`OSError` is raised if the source code cannot
576-
be retrieved.
576+
be retrieved. This
577+
will fail with a :exc:`TypeError` if the object is a built-in module, class, or
578+
function.
577579

578580
.. versionchanged:: 3.3
579581
:exc:`OSError` is raised instead of :exc:`IOError`, now an alias of the
@@ -585,7 +587,9 @@ Retrieving source code
585587
Return the text of the source code for an object. The argument may be a module,
586588
class, method, function, traceback, frame, or code object. The source code is
587589
returned as a single string. An :exc:`OSError` is raised if the source code
588-
cannot be retrieved.
590+
cannot be retrieved. This
591+
will fail with a :exc:`TypeError` if the object is a built-in module, class, or
592+
function.
589593

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

0 commit comments

Comments
 (0)