]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-46417: Add _PyType_GetSubclasses() function (GH-30761)
authorVictor Stinner <vstinner@python.org>
Fri, 21 Jan 2022 22:29:10 +0000 (23:29 +0100)
committerGitHub <noreply@github.com>
Fri, 21 Jan 2022 22:29:10 +0000 (23:29 +0100)
commit8ee07dda139f3fa1d7c58a29532a98efc790568d
treeb55c7db28a923d035a718d80ee4f06bcb1066631
parent57d1855682dbeb9233ef3a531f9535c6442e9992
bpo-46417: Add _PyType_GetSubclasses() function (GH-30761)

Add a new _PyType_GetSubclasses() function to get type's subclasses.

_PyType_GetSubclasses(type) returns a list which holds strong
refererences to subclasses. It is safer than iterating on
type->tp_subclasses which yields weak references and can be modified
in the loop.

_PyType_GetSubclasses(type) now holds a reference to the tp_subclasses
dict while creating the list of subclasses.

set_collection_flag_recursive() of _abc.c now uses
_PyType_GetSubclasses().
Include/internal/pycore_object.h
Modules/_abc.c
Objects/typeobject.c