[3.13] gh-123091: Use more _Py_IsImmortalLoose() (GH-123602) (GH-123622)

Switch more _Py_IsImmortal(...) assertions to _Py_IsImmortalLoose(...)

The remaining calls to _Py_IsImmortal are in free-threaded-only code,
initialization of core objects, tests, and guards that fall back to
code that works with mortal objects.

(cherry picked from commit 57c471a688)
This commit is contained in:
Petr Viktorin 2024-09-03 12:36:42 +02:00 committed by GitHub
parent 7761ddcfed
commit d655c65561
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 3 deletions

View File

@ -1333,7 +1333,7 @@ FutureObj_get_state(FutureObj *fut, void *Py_UNUSED(ignored))
default: default:
assert (0); assert (0);
} }
assert(_Py_IsImmortal(ret)); assert(_Py_IsImmortalLoose(ret));
return ret; return ret;
} }

View File

@ -725,7 +725,7 @@ _PyStructSequence_FiniBuiltin(PyInterpreterState *interp, PyTypeObject *type)
assert(type->tp_name != NULL); assert(type->tp_name != NULL);
assert(type->tp_base == &PyTuple_Type); assert(type->tp_base == &PyTuple_Type);
assert((type->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN)); assert((type->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN));
assert(_Py_IsImmortal(type)); assert(_Py_IsImmortalLoose(type));
// Cannot delete a type if it still has subclasses // Cannot delete a type if it still has subclasses
if (_PyType_HasSubclasses(type)) { if (_PyType_HasSubclasses(type)) {

View File

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