Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c8c8233

Browse files
committed
It's ok for __repr__ to return unicode.
1 parent d7c43dd commit c8c8233

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

Objects/object.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -361,15 +361,8 @@ PyObject_Repr(PyObject *v)
361361
res = (*v->ob_type->tp_repr)(v);
362362
if (res == NULL)
363363
return NULL;
364-
if (PyUnicode_Check(res)) {
365-
PyObject* str;
366-
str = PyUnicode_AsEncodedString(res, NULL, NULL);
367-
Py_DECREF(res);
368-
if (str)
369-
res = str;
370-
else
371-
return NULL;
372-
}
364+
if (PyUnicode_Check(res))
365+
return res;
373366
if (!PyString_Check(res)) {
374367
PyErr_Format(PyExc_TypeError,
375368
"__repr__ returned non-string (type %.200s)",

0 commit comments

Comments
 (0)