Skip to content

Commit 77e54fe

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 6c667d0 commit 77e54fe

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
@@ -526,6 +526,8 @@ Retrieving source code
526526
object and the line number indicates where in the original source file the first
527527
line of code was found. An :exc:`OSError` is raised if the source code cannot
528528
be retrieved.
529+
A :exc:`TypeError` is raised if the object is a built-in module, class, or
530+
function.
529531

530532
.. versionchanged:: 3.3
531533
:exc:`OSError` is raised instead of :exc:`IOError`, now an alias of the
@@ -538,6 +540,8 @@ Retrieving source code
538540
class, method, function, traceback, frame, or code object. The source code is
539541
returned as a single string. An :exc:`OSError` is raised if the source code
540542
cannot be retrieved.
543+
A :exc:`TypeError` is raised if the object is a built-in module, class, or
544+
function.
541545

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

0 commit comments

Comments
 (0)