Docs: Fix built-in function `__self__` attribute descriptions (GH-159… · python/cpython@415ebff · GitHub
Skip to content

Commit 415ebff

Browse files
authored
Docs: Fix built-in function __self__ attribute descriptions (GH-159653)
Since PEP 3121, functions in C modules are bound to their module, so their __self__ is the module object. The inspect.isbuiltin docstring, the inspect attribute table and the data model reference still say it is None, as it was in Python 2. Describe it as the module object the function was defined in, or None.
1 parent 036d309 commit 415ebff

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎Doc/library/inspect.rst‎

Lines changed: 2 additions & 0 deletions

‎Doc/reference/datamodel.rst‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,8 @@ determined by the C function. Special read-only attributes:
863863
* :attr:`!__doc__` is the function's documentation string, or ``None`` if
864864
unavailable. See :attr:`function.__doc__`.
865865
* :attr:`!__name__` is the function's name. See :attr:`function.__name__`.
866-
* :attr:`!__self__` is set to ``None`` (but see the next item).
866+
* :attr:`!__self__` is the module object the function was defined in or
867+
``None`` if unavailable.
867868
* :attr:`!__module__` is the name of
868869
the module the function was defined in or ``None`` if unavailable.
869870
See :attr:`function.__module__`.

‎Lib/inspect.py‎

Lines changed: 2 additions & 1 deletion

0 commit comments

Comments
 (0)