Skip to content

Commit

Permalink
[3.13] pythongh-123091: Use more _Py_IsImmortalLoose() (pythonGH-123602)
Browse files Browse the repository at this point in the history
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 57c471a)
  • Loading branch information
encukou committed Sep 3, 2024
1 parent 7761ddc commit ea42534
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Modules/_asynciomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@ FutureObj_get_state(FutureObj *fut, void *Py_UNUSED(ignored))
default:
assert (0);
}
assert(_Py_IsImmortal(ret));
assert(_Py_IsImmortalLoose(ret));
return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion Objects/structseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ _PyStructSequence_FiniBuiltin(PyInterpreterState *interp, PyTypeObject *type)
assert(type->tp_name != NULL);
assert(type->tp_base == &PyTuple_Type);
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
if (_PyType_HasSubclasses(type)) {
Expand Down
2 changes: 1 addition & 1 deletion Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,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_IsImmortal(value->def));
assert(value->def == NULL || _Py_IsImmortalLoose(value->def));

Py_XDECREF(value->def->m_base.m_copy);
value->def->m_base.m_copy = NULL;
Expand Down

0 comments on commit ea42534

Please sign in to comment.