diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h index 7602248f956..f63e1da6fba 100644 --- a/Include/internal/pycore_object.h +++ b/Include/internal/pycore_object.h @@ -497,6 +497,9 @@ _Py_NewRefWithLock(PyObject *op) if (_Py_TryIncrefFast(op)) { return op; } +#ifdef Py_REF_DEBUG + _Py_IncRefTotal(_PyThreadState_GET()); +#endif _Py_INCREF_STAT_INC(); for (;;) { Py_ssize_t shared = _Py_atomic_load_ssize_relaxed(&op->ob_ref_shared);