Skip to content

Commit 7371bac

Browse files
committed
Fix refcount accounting
1 parent 1479821 commit 7371bac

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Include/refcount.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,10 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
307307
#endif
308308
_Py_INCREF_STAT_INC();
309309
#ifdef Py_REF_DEBUG
310-
_Py_INCREF_IncRefTotal();
310+
// Don't count the incref if the object is immortal.
311+
if (_Py_IsImmortal(op)) {
312+
_Py_INCREF_IncRefTotal();
313+
}
311314
#endif
312315
#endif
313316
}

0 commit comments

Comments
 (0)