summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Include/internal/pycore_object.h2
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2024-05-13-16-00-05.gh-issue-118997.GWqWdt.rst4
2 files changed, 5 insertions, 1 deletions
diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h
index 7a2f13a..63e74a6 100644
--- a/Include/internal/pycore_object.h
+++ b/Include/internal/pycore_object.h
@@ -80,7 +80,7 @@ static inline void _Py_SetImmortal(PyObject *op)
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);
}
diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-05-13-16-00-05.gh-issue-118997.GWqWdt.rst b/Misc/NEWS.d/next/Core and Builtins/2024-05-13-16-00-05.gh-issue-118997.GWqWdt.rst
new file mode 100644
index 0000000..85d6dc8
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2024-05-13-16-00-05.gh-issue-118997.GWqWdt.rst
@@ -0,0 +1,4 @@
+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.