Skip to content

Commit b613208

Browse files
authored
gh-98239: Document that inspect.getsource() can raise TypeError (#101689)
1 parent 58d2b30 commit b613208

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
@@ -574,6 +574,8 @@ Retrieving source code
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
576576
be retrieved.
577+
A :exc:`TypeError` is raised 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
@@ -586,6 +588,8 @@ Retrieving source code
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
588590
cannot be retrieved.
591+
A :exc:`TypeError` is raised 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)