SIGN IN SIGN UP

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().
V
Victor Stinner committed
8ee07dda139f3fa1d7c58a29532a98efc790568d
Parent: 57d1855
Committed by GitHub <noreply@github.com> on 1/21/2022, 10:29:10 PM