diff options
author | Victor Stinner <vstinner@python.org> | 2022-01-21 22:29:10 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-21 22:29:10 (GMT) |
commit | 8ee07dda139f3fa1d7c58a29532a98efc790568d (patch) | |
tree | b55c7db28a923d035a718d80ee4f06bcb1066631 /Include | |
parent | 57d1855682dbeb9233ef3a531f9535c6442e9992 (diff) | |
download | cpython-8ee07dda139f3fa1d7c58a29532a98efc790568d.zip cpython-8ee07dda139f3fa1d7c58a29532a98efc790568d.tar.gz cpython-8ee07dda139f3fa1d7c58a29532a98efc790568d.tar.bz2 |
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().
Diffstat (limited to 'Include')
-rw-r--r-- | Include/internal/pycore_object.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h index 0348563..be308cd 100644 --- a/Include/internal/pycore_object.h +++ b/Include/internal/pycore_object.h @@ -220,11 +220,12 @@ static inline PyObject **_PyObject_ManagedDictPointer(PyObject *obj) return ((PyObject **)obj)-3; } -PyObject ** _PyObject_DictPointer(PyObject *); -int _PyObject_VisitInstanceAttributes(PyObject *self, visitproc visit, void *arg); -void _PyObject_ClearInstanceAttributes(PyObject *self); -void _PyObject_FreeInstanceAttributes(PyObject *self); -int _PyObject_IsInstanceDictEmpty(PyObject *); +extern PyObject ** _PyObject_DictPointer(PyObject *); +extern int _PyObject_VisitInstanceAttributes(PyObject *self, visitproc visit, void *arg); +extern void _PyObject_ClearInstanceAttributes(PyObject *self); +extern void _PyObject_FreeInstanceAttributes(PyObject *self); +extern int _PyObject_IsInstanceDictEmpty(PyObject *); +extern PyObject* _PyType_GetSubclasses(PyTypeObject *); #ifdef __cplusplus } |