diff --git a/Objects/codeobject.c b/Objects/codeobject.c index bb8ffa794a96d3..767a53fc1741ad 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -1923,4 +1923,10 @@ _PyStaticCode_Dealloc(PyCodeObject *co) PyObject_ClearWeakRefs((PyObject *)co); co->co_weakreflist = NULL; } +#ifdef Py_REF_DEBUG + /* Adjust _Py_RefTotal and refcnt for Py_INCREF/Py_DECREF + * on immortal codeobjects */ + _Py_RefTotal += 999999999 - Py_REFCNT((PyObject *)co); + Py_SET_REFCNT((PyObject*)co, 999999999); +#endif }