Skip to content

Commit b86d783

Browse files
sobolevnAlexWaygoodJelleZijlstra
authored
bpo-40838: document getdoc, getmodule, getsourcefile in inspect returns None (#30575)
Co-authored-by: Alex Waygood <[email protected]> Co-authored-by: Jelle Zijlstra <[email protected]>
1 parent 33880b4 commit b86d783

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
@@ -512,6 +512,7 @@ Retrieving source code
512512
If the documentation string for an object is not provided and the object is
513513
a class, a method, a property or a descriptor, retrieve the documentation
514514
string from the inheritance hierarchy.
515+
Return ``None`` if the documentation string is invalid or missing.
515516

516517
.. versionchanged:: 3.5
517518
Documentation strings are now inherited if not overridden.
@@ -535,12 +536,14 @@ Retrieving source code
535536

536537
.. function:: getmodule(object)
537538

538-
Try to guess which module an object was defined in.
539+
Try to guess which module an object was defined in. Return ``None``
540+
if the module cannot be determined.
539541

540542

541543
.. function:: getsourcefile(object)
542544

543-
Return the name of the Python source file in which an object was defined. This
545+
Return the name of the Python source file in which an object was defined
546+
or ``None`` if no way can be identified to get the source. This
544547
will fail with a :exc:`TypeError` if the object is a built-in module, class, or
545548
function.
546549

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)