Commit 0a54cf12 authored by Victor Stinner's avatar Victor Stinner

Fix PyObject_Repr(): don't call PyUnicode_READY() if res is NULL

parent b37b1742
......@@ -378,7 +378,9 @@ PyObject_Repr(PyObject *v)
return PyUnicode_FromFormat("<%s object at %p>",
v->ob_type->tp_name, v);
res = (*v->ob_type->tp_repr)(v);
if (res != NULL && !PyUnicode_Check(res)) {
if (res == NULL)
return NULL;
if (!PyUnicode_Check(res)) {
PyErr_Format(PyExc_TypeError,
"__repr__ returned non-string (type %.200s)",
res->ob_type->tp_name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment