https://github.com/python/cpython/commit/bd1e9509a4475266b21ff432c7875efc289bc0ca
commit: bd1e9509a4475266b21ff432c7875efc289bc0ca
branch: 3.12
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2024-05-18T16:56:27-04:00
summary:
[3.12] gh-118997: Fix _Py_ClearImmortal() assertion (#119001)
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.
files:
A Misc/NEWS.d/next/Core and
Builtins/2024-05-13-16-00-05.gh-issue-118997.GWqWdt.rst
M Include/internal/pycore_object.h
diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h
index 7a2f13a21bda76..63e74a65f43c01 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 00000000000000..85d6dc80ed9c24
--- /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.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]