8000 [3.12] gh-118997: Fix _Py_ClearImmortal() assertion (#119001) · python/cpython@bd1e950 · GitHub
[go: up one dir, main page]

Skip to content

Commit bd1e950

Browse files
[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.
1 parent bb44a82 commit bd1e950

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Include/internal/pycore_object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static inline void _Py_SetImmortal(PyObject *op)
8080
static inline void _Py_ClearImmortal(PyObject *op)
8181
{
8282
if (op) {
83-
assert(op->ob_refcnt == _Py_IMMORTAL_REFCNT);
83+
assert(_Py_IsImmortal(op));
8484
op->ob_refcnt = 1;
8585
Py_DECREF(op);
8686
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fix _Py_ClearImmortal() assertion: use _Py_IsImmortal() to tolerate
2+
reference count lower than _Py_IMMORTAL_REFCNT. Fix the assertion for the
3+
stable ABI, when a C extension is built with Python 3.11 or lower. Patch by
4+
Victor Stinner.

0 commit comments

Comments
 (0)
0