GeezerVison is showing github.com — gh-98239: Document that `inspect.getsource()` can raise `TypeError` (… · python/cpython@202e16e
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: Doc/library/inspect.rst +4Lines changed: 4 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -553,6 +553,8 @@ Retrieving source code |
553 | 553 | object and the line number indicates where in the original source file the first |
554 | 554 | line of code was found. An :exc:`OSError` is raised if the source code cannot |
555 | 555 | be retrieved. |
| 556 | + A :exc:`TypeError` is raised if the object is a built-in module, class, or |
| 557 | + function. |
556 | 558 |
|
557 | 559 | .. versionchanged:: 3.3 |
558 | 560 | :exc:`OSError` is raised instead of :exc:`IOError`, now an alias of the |
@@ -565,6 +567,8 @@ Retrieving source code |
565 | 567 | class, method, function, traceback, frame, or code object. The source code is |
566 | 568 | returned as a single string. An :exc:`OSError` is raised if the source code |
567 | 569 | cannot be retrieved. |
| 570 | + A :exc:`TypeError` is raised if the object is a built-in module, class, or |
| 571 | + function. |
568 | 572 |
|
569 | 573 | .. versionchanged:: 3.3 |
570 | 574 | :exc:`OSError` is raised instead of :exc:`IOError`, now an alias of the |
|