Skip to content

Commit c925326

Browse files
committed
[3.12] pythongh-123091: Use more _Py_IsImmortalLoose() (pythonGH-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. (For this 3.12 backport commit, I re-checked all calls to _Py_IsImmortal; the changed calls are different from the commits to 3.13 & 3.14.)
1 parent 350edea commit c925326

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

Include/internal/pycore_object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static inline void _Py_SetImmortal(PyObject *op)
109109
static inline void _Py_ClearImmortal(PyObject *op)
110110
{
111111
if (op) {
112-
assert(_Py_IsImmortal(op));
112+
assert(_Py_IsImmortalLoose(op));
113113
op->ob_refcnt = 1;
114114
Py_DECREF(op);
115115
}

Objects/structseq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ _PyStructSequence_FiniBuiltin(PyInterpreterState *interp, PyTypeObject *type)
623623
assert(type->tp_name != NULL);
624624
assert(type->tp_base == &PyTuple_Type);
625625
assert((type->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN));
626-
assert(_Py_IsImmortal(type));
626+
assert(_Py_IsImmortalLoose(type));
627627

628628
// Cannot delete a type if it still has subclasses
629629
if (_PyType_HasSubclasses(type)) {

Python/import.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ _extensions_cache_delete(PyObject *filename, PyObject *name)
10801080
However, this decref would be problematic if the module def were
10811081
dynamically allocated, it were the last ref, and this function
10821082
were called with an interpreter other than the def's owner. */
1083-
assert(_Py_IsImmortal(entry->value));
1083+
assert(_Py_IsImmortalLoose(entry->value));
10841084
entry->value = NULL;
10851085

10861086
finally:

0 commit comments

Comments
 (0)