Skip to content

Docs: Include built-in functions among weakly referenceable objects - #158425

Open
esadomer wants to merge 1 commit into
python:mainfrom
esadomer:b01-p003-weakref-builtin-functions
Open

esadomer wants to merge 1 commit into
python:mainfrom
esadomer:b01-p003-weakref-builtin-functions

Conversation

@esadomer

Copy link
Copy Markdown
Contributor

Summary

Include built-in functions in the list of objects that support weak references. The current text excludes functions written in C, although built-in functions have supported weak references since Python 3.5.

import weakref

assert weakref.ref(len)() is len

The wording names built-in functions specifically: it does not imply that every callable implemented in C supports weak references. For example, the list.append method descriptor still raises TypeError.

Validation

  • Built CPython 3.16.0a0 from the checkout with PCbuild\build.bat -p x64 -d -M on Windows 10 x64 (MSVC 19.30).
  • PCbuild\amd64\python_d.exe -m test test_weakref: SUCCESS (run=139, skipped=4).
  • Verified the examples and boundary cases with the same debug interpreter.
  • python -m sphinx -W --keep-going -j 1 -b html -d build/doctrees . build/html from Doc: incremental HTML build passed with Sphinx 8.2.3. The clean baseline build reported an existing duplicate customization label in using/windows.rst and reference/datamodel.rst.
  • python -m sphinxlint Doc/library/weakref.rst, PCbuild\amd64\python_d.exe Tools\patchcheck\patchcheck.py, and git diff --check: passed.

This changes documentation only. No NEWS entry is needed. The full interpreter test suite was not run.

@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news labels Sep 29, 2026
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34831730 | 📁 Comparing 49033d9 against main (84d4601)

  🔍 Preview build  

1 file changed
± library/weakref.html

@esadomer
esadomer marked this pull request as ready for review September 29, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant