SIGN IN SIGN UP
python / cpython UNCLAIMED

The Python programming language

0 0 93 Python

GH-135552: Make the GC clear weakrefs later (GH-136189)

Fix a bug caused by the garbage collector clearing weakrefs too early.  The
weakrefs in the ``tp_subclasses`` dictionary are needed in order to correctly
invalidate type caches (for example, by calling ``PyType_Modified()``).
Clearing weakrefs before calling finalizers causes the caches to not be
correctly invalidated.  That can cause crashes since the caches can refer to
invalid objects.  Defer the clearing of weakrefs without callbacks until after
finalizers are executed.
N
Neil Schemenauer committed
350c58ba4ee13019b0cde70b49bfeadc63f4ceb8
Parent: deb385a
Committed by GitHub <noreply@github.com> on 8/7/2025, 11:32:17 PM