]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
It's ok for __repr__ to return unicode.
authorGuido van Rossum <guido@python.org>
Fri, 4 May 2007 05:14:29 +0000 (05:14 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 4 May 2007 05:14:29 +0000 (05:14 +0000)
Objects/object.c

index 81f5669453538d22e1103e521d9b22e147c268b0..8597d888fb75003bfceaf4c746034e06da41e495 100644 (file)
@@ -361,15 +361,8 @@ PyObject_Repr(PyObject *v)
                res = (*v->ob_type->tp_repr)(v);
                if (res == NULL)
                        return NULL;
-               if (PyUnicode_Check(res)) {
-                       PyObject* str;
-                       str = PyUnicode_AsEncodedString(res, NULL, NULL);
-                       Py_DECREF(res);
-                       if (str)
-                               res = str;
-                       else
-                               return NULL;
-               }
+               if (PyUnicode_Check(res))
+                       return res;
                if (!PyString_Check(res)) {
                        PyErr_Format(PyExc_TypeError,
                                     "__repr__ returned non-string (type %.200s)",