From: Marc-André Lemburg Date: Mon, 3 Jul 2000 09:57:53 +0000 (+0000) Subject: If auto-conversion fails, the Unicode codecs will return NULL. X-Git-Tag: v2.0b1~1112 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=891bc6548677fd0542fd715713f082be6f78e54e;p=thirdparty%2FPython%2Fcpython.git If auto-conversion fails, the Unicode codecs will return NULL. This is now checked and the error passed on to the caller. --- diff --git a/Objects/object.c b/Objects/object.c index 7f38dff6e29e..80a6e852aa3b 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -268,10 +268,11 @@ PyObject_Repr(v) if (PyUnicode_Check(res)) { PyObject* str; str = PyUnicode_AsEncodedString(res, NULL, NULL); - if (str) { - Py_DECREF(res); + Py_DECREF(res); + if (str) res = str; - } + else + return NULL; } if (!PyString_Check(res)) { PyErr_Format(PyExc_TypeError, @@ -310,14 +311,15 @@ PyObject_Str(v) } if (res == NULL) return NULL; - if (PyUnicode_Check(res)) { - PyObject* str; - str = PyUnicode_AsEncodedString(res, NULL, NULL); - if (str) { - Py_DECREF(res); - res = str; - } - } + if (PyUnicode_Check(res)) { + PyObject* str; + str = PyUnicode_AsEncodedString(res, NULL, NULL); + Py_DECREF(res); + if (str) + res = str; + else + return NULL; + } if (!PyString_Check(res)) { PyErr_Format(PyExc_TypeError, "__str__ returned non-string (type %.200s)",