]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-46417: remove_subclass() clears tp_subclasses (GH-30793)
authorVictor Stinner <vstinner@python.org>
Sat, 22 Jan 2022 15:53:30 +0000 (16:53 +0100)
committerGitHub <noreply@github.com>
Sat, 22 Jan 2022 15:53:30 +0000 (16:53 +0100)
commit2d03b73cc9c0dada3243eab1373a46dbd98d24a0
treea5540d769b1f1c8e2f05007df3903736b04932a9
parentf1c6ae3270913e095d24ae13ecf96f5a32c8c503
bpo-46417: remove_subclass() clears tp_subclasses (GH-30793)

The remove_subclass() function now deletes the dictionary when
removing the last subclass (if the dictionary becomes empty) to save
memory: set PyTypeObject.tp_subclasses to NULL. remove_subclass() is
called when a type is deallocated.

_PyType_GetSubclasses() no longer holds a reference to tp_subclasses:
its loop cannot modify tp_subclasses.
Lib/test/test_descr.py
Objects/typeobject.c