]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-123091: Use more _Py_IsImmortalLoose() (GH-123602) (GH-123622)
authorPetr Viktorin <encukou@gmail.com>
Tue, 3 Sep 2024 10:36:42 +0000 (12:36 +0200)
committerGitHub <noreply@github.com>
Tue, 3 Sep 2024 10:36:42 +0000 (12:36 +0200)
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 57c471a6880956338549380fc5fb35c986937901)

Modules/_asynciomodule.c
Objects/structseq.c
Python/import.c

index 3babd33eaabf45f8ce33780c512ebf145479c184..4b0aa0503f5231ed93d42368f292bb52fac617d9 100644 (file)
@@ -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;
 }
 
index 94f09b3ee0a337766f448c90abe29bbcf263b76a..ee3dbf9d4c047ae5ee7f2ddfe6439f9f32d37cf9 100644 (file)
@@ -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)) {
index 88f6a7ab57a20c4fcc41b56cc066ca017fa5cf69..1056ddd370befb990f41875863d220bda48c626a 100644 (file)
@@ -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;