From b6132085ca5418f714eff6e31d1d03369d3fd1d9 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Thu, 23 Mar 2023 22:35:02 +0300 Subject: [PATCH] gh-98239: Document that `inspect.getsource()` can raise `TypeError` (#101689) --- Doc/library/inspect.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst index ccf240193d3..88f843c03b1 100644 --- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -574,6 +574,8 @@ Retrieving source code object and the line number indicates where in the original source file the first line of code was found. An :exc:`OSError` is raised if the source code cannot be retrieved. + A :exc:`TypeError` is raised if the object is a built-in module, class, or + function. .. versionchanged:: 3.3 :exc:`OSError` is raised instead of :exc:`IOError`, now an alias of the @@ -586,6 +588,8 @@ Retrieving source code class, method, function, traceback, frame, or code object. The source code is returned as a single string. An :exc:`OSError` is raised if the source code cannot be retrieved. + A :exc:`TypeError` is raised if the object is a built-in module, class, or + function. .. versionchanged:: 3.3 :exc:`OSError` is raised instead of :exc:`IOError`, now an alias of the