summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 0355303..fcd81b8 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1326,7 +1326,8 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
}
Py_INCREF(name);
- PyUnicode_InternInPlace(&name);
+ PyInterpreterState *interp = _PyInterpreterState_GET();
+ _PyUnicode_InternMortal(interp, &name);
if (tp->tp_setattro != NULL) {
err = (*tp->tp_setattro)(v, name, value);
Py_DECREF(name);
@@ -2409,6 +2410,13 @@ _Py_NewReferenceNoTotal(PyObject *op)
void
_Py_SetImmortalUntracked(PyObject *op)
{
+#ifdef Py_DEBUG
+ // For strings, use _PyUnicode_InternImmortal instead.
+ if (PyUnicode_CheckExact(op)) {
+ assert(PyUnicode_CHECK_INTERNED(op) == SSTATE_INTERNED_IMMORTAL
+ || PyUnicode_CHECK_INTERNED(op) == SSTATE_INTERNED_IMMORTAL_STATIC);
+ }
+#endif
#ifdef Py_GIL_DISABLED
op->ob_tid = _Py_UNOWNED_TID;
op->ob_ref_local = _Py_IMMORTAL_REFCNT_LOCAL;