Skip to content

Commit ed75d21

Browse files
bpo-40838: document getdoc, getmodule, getsourcefile in inspect returns None (GH-30575)
Co-authored-by: Alex Waygood <[email protected]> Co-authored-by: Jelle Zijlstra <[email protected]> (cherry picked from commit b86d783) Co-authored-by: Nikita Sobolev <[email protected]>
1 parent 94e21cf commit ed75d21

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Doc/library/inspect.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ Retrieving source code
482482
If the documentation string for an object is not provided and the object is
483483
a class, a method, a property or a descriptor, retrieve the documentation
484484
string from the inheritance hierarchy.
485+
Return ``None`` if the documentation string is invalid or missing.
485486

486487
.. versionchanged:: 3.5
487488
Documentation strings are now inherited if not overridden.
@@ -505,12 +506,14 @@ Retrieving source code
505506

506507
.. function:: getmodule(object)
507508

508-
Try to guess which module an object was defined in.
509+
Try to guess which module an object was defined in. Return ``None``
510+
if the module cannot be determined.
509511

510512

511513
.. function:: getsourcefile(object)
512514

513-
Return the name of the Python source file in which an object was defined. This
515+
Return the name of the Python source file in which an object was defined
516+
or ``None`` if no way can be identified to get the source. This
514517
will fail with a :exc:`TypeError` if the object is a built-in module, class, or
515518
function.
516519

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Document that :func:`inspect.getdoc`, :func:`inspect.getmodule`, and
2+
:func:`inspect.getsourcefile` might return ``None``.

0 commit comments

Comments
 (0)