diff options
-rw-r--r-- | Objects/unicodeobject.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 5116404..e69bf01 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -2275,17 +2275,23 @@ PyUnicode_FromString(const char *u) PyObject * _PyUnicode_FromId(_Py_Identifier *id) { - if (!id->object) { - id->object = PyUnicode_DecodeUTF8Stateful(id->string, - strlen(id->string), - NULL, NULL); - if (!id->object) - return NULL; - PyUnicode_InternInPlace(&id->object); - assert(!id->next); - id->next = static_strings; - static_strings = id; + if (id->object) { + return id->object; + } + + PyObject *obj; + obj = PyUnicode_DecodeUTF8Stateful(id->string, + strlen(id->string), + NULL, NULL); + if (!obj) { + return NULL; } + PyUnicode_InternInPlace(&obj); + + assert(!id->next); + id->object = obj; + id->next = static_strings; + static_strings = id; return id->object; } |