GH-127705: Fix _Py_RefcntAdd to handle objects becoming immortal (GH-131140)

This commit is contained in:
Mark Shannon 2025-03-12 16:54:10 +00:00 committed by GitHub
parent 061da44bac
commit f30376c650
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 11 deletions

View file

@ -15982,7 +15982,7 @@ _PyUnicode_ClearInterned(PyInterpreterState *interp)
case SSTATE_INTERNED_MORTAL:
// Restore 2 references held by the interned dict; these will
// be decref'd by clear_interned_dict's PyDict_Clear.
Py_SET_REFCNT(s, Py_REFCNT(s) + 2);
_Py_RefcntAdd(s, 2);
#ifdef Py_REF_DEBUG
/* let's be pedantic with the ref total */
_Py_IncRefTotal(_PyThreadState_GET());