]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
If auto-conversion fails, the Unicode codecs will return NULL.
authorMarc-André Lemburg <mal@egenix.com>
Mon, 3 Jul 2000 09:57:53 +0000 (09:57 +0000)
committerMarc-André Lemburg <mal@egenix.com>
Mon, 3 Jul 2000 09:57:53 +0000 (09:57 +0000)
This is now checked and the error passed on to the caller.

Objects/object.c

index 7f38dff6e29ea4840be96fcb3f269d1799f3a8db..80a6e852aa3bfe4acc2842527de16bda4a43b80c 100644 (file)
@@ -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)",