GH-125174: Make immortal objects more robust, following design from PEP 683 (GH-125251)

This commit is contained in:
Mark Shannon 2024-10-10 18:19:08 +01:00 committed by GitHub
parent 01fc3b34cc
commit c9014374c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 61 additions and 72 deletions

View file

@ -381,7 +381,7 @@ dummy_func(
EXIT_IF(!PyLong_CheckExact(value_o));
STAT_INC(TO_BOOL, hit);
if (_PyLong_IsZero((PyLongObject *)value_o)) {
assert(_Py_IsImmortalLoose(value_o));
assert(_Py_IsImmortal(value_o));
DEAD(value);
res = PyStackRef_False;
}
@ -412,7 +412,7 @@ dummy_func(
EXIT_IF(!PyUnicode_CheckExact(value_o));
STAT_INC(TO_BOOL, hit);
if (value_o == &_Py_STR(empty)) {
assert(_Py_IsImmortalLoose(value_o));
assert(_Py_IsImmortal(value_o));
DEAD(value);
res = PyStackRef_False;
}

View file

@ -402,7 +402,7 @@
}
STAT_INC(TO_BOOL, hit);
if (_PyLong_IsZero((PyLongObject *)value_o)) {
assert(_Py_IsImmortalLoose(value_o));
assert(_Py_IsImmortal(value_o));
res = PyStackRef_False;
}
else {
@ -455,7 +455,7 @@
}
STAT_INC(TO_BOOL, hit);
if (value_o == &_Py_STR(empty)) {
assert(_Py_IsImmortalLoose(value_o));
assert(_Py_IsImmortal(value_o));
res = PyStackRef_False;
}
else {

View file

@ -7840,7 +7840,7 @@
DEOPT_IF(!PyLong_CheckExact(value_o), TO_BOOL);
STAT_INC(TO_BOOL, hit);
if (_PyLong_IsZero((PyLongObject *)value_o)) {
assert(_Py_IsImmortalLoose(value_o));
assert(_Py_IsImmortal(value_o));
res = PyStackRef_False;
}
else {
@ -7902,7 +7902,7 @@
DEOPT_IF(!PyUnicode_CheckExact(value_o), TO_BOOL);
STAT_INC(TO_BOOL, hit);
if (value_o == &_Py_STR(empty)) {
assert(_Py_IsImmortalLoose(value_o));
assert(_Py_IsImmortal(value_o));
res = PyStackRef_False;
}
else {

View file

@ -1051,7 +1051,7 @@ del_cached_def(struct extensions_cache_value *value)
However, this decref would be problematic if the module def were
dynamically allocated, it were the last ref, and this function
were called with an interpreter other than the def's owner. */
assert(value->def == NULL || _Py_IsImmortalLoose(value->def));
assert(value->def == NULL || _Py_IsImmortal(value->def));
Py_XDECREF(value->def->m_base.m_copy);
value->def->m_base.m_copy = NULL;