Skip to content
Prev Previous commit
Down downgrade from static immortal to plain immortal
  • Loading branch information
markshannon committed Dec 11, 2024
commit ddff59692c3af17c3a52d207a9d62fbae87da08d
4 changes: 4 additions & 0 deletions Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -2521,6 +2521,10 @@ _Py_SetImmortalUntracked(PyObject *op)
|| PyUnicode_CHECK_INTERNED(op) == SSTATE_INTERNED_IMMORTAL_STATIC);
}
#endif
// Check if already immortal to avoid degrading from static immortal to plain immortal
if (_Py_IsImmortal(op)) {
return;
}
#ifdef Py_GIL_DISABLED
op->ob_tid = _Py_UNOWNED_TID;
op->ob_ref_local = _Py_IMMORTAL_REFCNT_LOCAL;
Expand Down