diff --git a/Objects/stringobject.c b/Objects/stringobject.c index e29ed4806fe..b40351afcba 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -3513,7 +3513,8 @@ _PyString_Resize(PyObject **pv, int newsize) register PyObject *v; register PyStringObject *sv; v = *pv; - if (!PyString_Check(v) || v->ob_refcnt != 1 || newsize < 0) { + if (!PyString_Check(v) || v->ob_refcnt != 1 || newsize < 0 || + PyString_CHECK_INTERNED(v)) { *pv = 0; Py_DECREF(v); PyErr_BadInternalCall(); diff --git a/Python/ceval.c b/Python/ceval.c index 4dd31ab9bab..4c9bdeda136 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4253,7 +4253,7 @@ string_concatenate(PyObject *v, PyObject *w, } } - if (v->ob_refcnt == 1) { + if (v->ob_refcnt == 1 && !PyString_CHECK_INTERNED(v)) { /* Now we own the last reference to 'v', so we can resize it * in-place. */