Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1a2652c

Browse files
authored
Cleanup clear_static_tp_subclasses() (#106276)
Only iterate on the dictionary if Python is built with assertions: subclass is only needed when Python is built with assertions.
1 parent 80b3d8f commit 1a2652c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Objects/typeobject.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5009,6 +5009,7 @@ clear_static_tp_subclasses(PyTypeObject *type)
50095009
going to leak. This mostly only affects embedding scenarios.
50105010
*/
50115011

5012+
#ifndef NDEBUG
50125013
// For now we just do a sanity check and then clear tp_subclasses.
50135014
Py_ssize_t i = 0;
50145015
PyObject *key, *ref; // borrowed ref
@@ -5021,6 +5022,7 @@ clear_static_tp_subclasses(PyTypeObject *type)
50215022
assert(!(subclass->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN));
50225023
Py_DECREF(subclass);
50235024
}
5025+
#endif
50245026

50255027
clear_tp_subclasses(type);
50265028
}

0 commit comments

Comments
 (0)