From: Victor Stinner Date: Thu, 1 Dec 2011 02:22:44 +0000 (+0100) Subject: Fix PyObject_Repr(): don't call PyUnicode_READY() if res is NULL X-Git-Tag: v3.3.0a1~701 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0a54cf12a09d731cd043f814142744f5de0a91ee;p=python Fix PyObject_Repr(): don't call PyUnicode_READY() if res is NULL --- diff --git a/Objects/object.c b/Objects/object.c index eea55318eb..ad31738d49 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -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);