mirror of
https://github.com/python/cpython.git
synced 2025-07-18 16:55:20 +00:00
bpo-39573: Add Py_SET_REFCNT() function (GH-18389)
Add a Py_SET_REFCNT() function to set the reference counter of an object.
This commit is contained in:
parent
a93c51e3a8
commit
c86a11221d
7 changed files with 30 additions and 14 deletions
|
@ -1903,7 +1903,7 @@ unicode_dealloc(PyObject *unicode)
|
|||
|
||||
case SSTATE_INTERNED_MORTAL:
|
||||
/* revive dead object temporarily for DelItem */
|
||||
Py_REFCNT(unicode) = 3;
|
||||
Py_SET_REFCNT(unicode, 3);
|
||||
if (PyDict_DelItem(interned, unicode) != 0) {
|
||||
_PyErr_WriteUnraisableMsg("deletion of interned string failed",
|
||||
NULL);
|
||||
|
@ -15367,7 +15367,7 @@ PyUnicode_InternInPlace(PyObject **p)
|
|||
}
|
||||
/* The two references in interned are not counted by refcnt.
|
||||
The deallocator will take care of this */
|
||||
Py_REFCNT(s) -= 2;
|
||||
Py_SET_REFCNT(s, Py_REFCNT(s) - 2);
|
||||
_PyUnicode_STATE(s).interned = SSTATE_INTERNED_MORTAL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue