Skip to content

Commit 57c471a

Browse files
authored
gh-123091: Use more _Py_IsImmortalLoose() (GH-123602)
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.
1 parent 5002f17 commit 57c471a

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

Diff for: Include/internal/pycore_object.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ static inline void
314314
_Py_INCREF_TYPE(PyTypeObject *type)
315315
{
316316
if (!_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE)) {
317-
assert(_Py_IsImmortal(type));
317+
assert(_Py_IsImmortalLoose(type));
318318
return;
319319
}
320320

@@ -354,7 +354,7 @@ static inline void
354354
_Py_DECREF_TYPE(PyTypeObject *type)
355355
{
356356
if (!_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE)) {
357-
assert(_Py_IsImmortal(type));
357+
assert(_Py_IsImmortalLoose(type));
358358
return;
359359
}
360360

Diff for: Modules/_asynciomodule.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ FutureObj_get_state(FutureObj *fut, void *Py_UNUSED(ignored))
13871387
default:
13881388
assert (0);
13891389
}
1390-
assert(_Py_IsImmortal(ret));
1390+
assert(_Py_IsImmortalLoose(ret));
13911391
return ret;
13921392
}
13931393

Diff for: Objects/structseq.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ _PyStructSequence_FiniBuiltin(PyInterpreterState *interp, PyTypeObject *type)
725725
assert(type->tp_name != NULL);
726726
assert(type->tp_base == &PyTuple_Type);
727727
assert((type->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN));
728-
assert(_Py_IsImmortal(type));
728+
assert(_Py_IsImmortalLoose(type));
729729

730730
// Cannot delete a type if it still has subclasses
731731
if (_PyType_HasSubclasses(type)) {

Diff for: Python/import.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ del_cached_def(struct extensions_cache_value *value)
10491049
However, this decref would be problematic if the module def were
10501050
dynamically allocated, it were the last ref, and this function
10511051
were called with an interpreter other than the def's owner. */
1052-
assert(value->def == NULL || _Py_IsImmortal(value->def));
1052+
assert(value->def == NULL || _Py_IsImmortalLoose(value->def));
10531053

10541054
Py_XDECREF(value->def->m_base.m_copy);
10551055
value->def->m_base.m_copy = NULL;

0 commit comments

Comments
 (0)