]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-102960: Make frames weak-referenceable (#152838)
authorŁukasz Langa <lukasz@langa.pl>
Tue, 14 Jul 2026 23:58:14 +0000 (01:58 +0200)
committerGitHub <noreply@github.com>
Tue, 14 Jul 2026 23:58:14 +0000 (01:58 +0200)
commit6ae740c0a8cc67d71b6deebf459f57773cc06961
tree2a67942056fd51b101d02d98be1360f931c17e3e
parentb704b647b2295924ebaf8d20ddf88925095039bb
gh-102960: Make frames weak-referenceable (#152838)

Add an explicit f_weakreflist field to the frame object, following the
same pattern as generators and coroutines, including free-threading-safe
weakref clearing via FT_CLEAR_WEAKREFS() in frame_dealloc().

Py_TPFLAGS_MANAGED_WEAKREF is not used because static builtin types
must not carry it (see init_static_type()) and the pre-header would
cost two extra words per frame instead of one.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Doc/library/weakref.rst
Doc/whatsnew/3.16.rst
Include/internal/pycore_frame.h
Lib/test/test_frame.py
Lib/test/test_sys.py
Misc/NEWS.d/next/Core_and_Builtins/2026-07-01-12-00-00.gh-issue-102960.fR8kJa.rst [new file with mode: 0644]
Objects/frameobject.c