Fix _Py_ClearImmortal() assertion: use _Py_IsImmortal() to tolerate
reference count lower than _Py_IMMORTAL_REFCNT. Fix the assertion for
the stable ABI, when a C extension is built with Python 3.11 or
lower.
static inline void _Py_ClearImmortal(PyObject *op)
{
if (op) {
- assert(op->ob_refcnt == _Py_IMMORTAL_REFCNT);
+ assert(_Py_IsImmortal(op));
op->ob_refcnt = 1;
Py_DECREF(op);
}
--- /dev/null
+Fix _Py_ClearImmortal() assertion: use _Py_IsImmortal() to tolerate
+reference count lower than _Py_IMMORTAL_REFCNT. Fix the assertion for the
+stable ABI, when a C extension is built with Python 3.11 or lower. Patch by
+Victor Stinner.