Skip to content

Docs: fix built-in function __self__ attribute descriptions - #159653

Open
crypt0lith wants to merge 1 commit into
python:mainfrom
crypt0lith:fix/builtin-func-self-docs
Open

crypt0lith wants to merge 1 commit into
python:mainfrom
crypt0lith:fix/builtin-func-self-docs

Conversation

@crypt0lith

Copy link
Copy Markdown

Since PEP 3121 (1a21451), functions in C modules are created with their module as self. The inspect.isbuiltin docstring, the inspect attribute table and the data model reference still say a built-in function's __self__ is None, as it was in Python 2.

Describe it as the module object the function was defined in, or None, mirroring __module__. It can still be None for built-in functions not defined in a module, such as the codec error handlers returned by codecs.lookup_error().

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.
@python-cla-bot

python-cla-bot Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app

bedevere-app Bot commented Oct 17, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #35215579 | 📁 Comparing f482def against main (0fedf78)

  🔍 Preview build  

2 files changed
± library/inspect.html
± reference/datamodel.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants