Skip to content

Commit 062d75a

Browse files
committed
gh-149816: Avoid allocating callback info for empty list
1 parent a33bd91 commit 062d75a

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Python/gc_free_threading.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,6 +1941,9 @@ invoke_gc_callback(PyThreadState *tstate, const char *phase,
19411941

19421942
/* The local variable cannot be rebound, check it for sanity */
19431943
assert(PyList_CheckExact(gcstate->callbacks));
1944+
if (PyList_GET_SIZE(gcstate->callbacks) == 0) {
1945+
return;
1946+
}
19441947

19451948
PyObject *info = Py_BuildValue("{sisnsnsnsd}",
19461949
"generation", generation,

0 commit comments

Comments
 (0)