mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
It's ok for __repr__ to return unicode.
This commit is contained in:
parent
d7c43dd5a2
commit
c8c82333c6
1 changed files with 2 additions and 9 deletions
|
@ -361,15 +361,8 @@ PyObject_Repr(PyObject *v)
|
||||||
res = (*v->ob_type->tp_repr)(v);
|
res = (*v->ob_type->tp_repr)(v);
|
||||||
if (res == NULL)
|
if (res == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (PyUnicode_Check(res)) {
|
if (PyUnicode_Check(res))
|
||||||
PyObject* str;
|
return res;
|
||||||
str = PyUnicode_AsEncodedString(res, NULL, NULL);
|
|
||||||
Py_DECREF(res);
|
|
||||||
if (str)
|
|
||||||
res = str;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (!PyString_Check(res)) {
|
if (!PyString_Check(res)) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"__repr__ returned non-string (type %.200s)",
|
"__repr__ returned non-string (type %.200s)",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue