PyUnicode_FromObject() ensures that its output is a ready string

This commit is contained in:
Victor Stinner 2011-10-01 03:09:33 +02:00
parent 67ca64ce54
commit d3a83d5eb3
1 changed files with 2 additions and 0 deletions

View File

@ -2068,6 +2068,8 @@ PyUnicode_FromObject(register PyObject *obj)
/* XXX Perhaps we should make this API an alias of /* XXX Perhaps we should make this API an alias of
PyObject_Str() instead ?! */ PyObject_Str() instead ?! */
if (PyUnicode_CheckExact(obj)) { if (PyUnicode_CheckExact(obj)) {
if (PyUnicode_READY(obj))
return NULL;
Py_INCREF(obj); Py_INCREF(obj);
return obj; return obj;
} }