]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Cleanup clear_static_tp_subclasses() (#106276)
authorVictor Stinner <vstinner@python.org>
Fri, 30 Jun 2023 10:39:55 +0000 (12:39 +0200)
committerGitHub <noreply@github.com>
Fri, 30 Jun 2023 10:39:55 +0000 (10:39 +0000)
Only iterate on the dictionary if Python is built with assertions:
subclass is only needed when Python is built with assertions.

Objects/typeobject.c

index cc389bc3d6fa1b3b555697e0b6f950af6cecd85a..e67945db9af33003c668122f5295323c0c006e8a 100644 (file)
@@ -5009,6 +5009,7 @@ clear_static_tp_subclasses(PyTypeObject *type)
        going to leak.  This mostly only affects embedding scenarios.
      */
 
+#ifndef NDEBUG
     // For now we just do a sanity check and then clear tp_subclasses.
     Py_ssize_t i = 0;
     PyObject *key, *ref;  // borrowed ref
@@ -5021,6 +5022,7 @@ clear_static_tp_subclasses(PyTypeObject *type)
         assert(!(subclass->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN));
         Py_DECREF(subclass);
     }
+#endif
 
     clear_tp_subclasses(type);
 }