]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-123091: Use more _Py_IsImmortalLoose() (GH-123602)
authorPetr Viktorin <encukou@gmail.com>
Mon, 2 Sep 2024 16:17:48 +0000 (18:17 +0200)
committerGitHub <noreply@github.com>
Mon, 2 Sep 2024 16:17:48 +0000 (18:17 +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.

Include/internal/pycore_object.h
Modules/_asynciomodule.c
Objects/structseq.c
Python/import.c

index 2ef0aaee0f82b3d35c8d9f7229c47991653dc2ed..64ff44bd7f5e431b8135c41d0f796ee4fd703ae2 100644 (file)
@@ -314,7 +314,7 @@ static inline void
 _Py_INCREF_TYPE(PyTypeObject *type)
 {
     if (!_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE)) {
-        assert(_Py_IsImmortal(type));
+        assert(_Py_IsImmortalLoose(type));
         return;
     }
 
@@ -354,7 +354,7 @@ static inline void
 _Py_DECREF_TYPE(PyTypeObject *type)
 {
     if (!_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE)) {
-        assert(_Py_IsImmortal(type));
+        assert(_Py_IsImmortalLoose(type));
         return;
     }
 
index 0a769c46b87ac8b85b2999beb2e4cc54cbced8fb..870084100a1b85770db210fc94a2911e9c57d37b 100644 (file)
@@ -1387,7 +1387,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 c9212ec1ac0d7ca50059bec81f29deaa7e39babe..a5ea0e2f81df57ae27920d0d4417e648147f7137 100644 (file)
@@ -1049,7 +1049,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;