diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-12-01 02:22:44 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-12-01 02:22:44 (GMT) |
commit | 0a54cf12a09d731cd043f814142744f5de0a91ee (patch) | |
tree | 71316cb5256cf78f4722cef1fb888437facd7865 /Objects/object.c | |
parent | b37b17423b294ee3bf5a28b8c358ca45cf681030 (diff) | |
download | cpython-0a54cf12a09d731cd043f814142744f5de0a91ee.zip cpython-0a54cf12a09d731cd043f814142744f5de0a91ee.tar.gz cpython-0a54cf12a09d731cd043f814142744f5de0a91ee.tar.bz2 |
Fix PyObject_Repr(): don't call PyUnicode_READY() if res is NULL
Diffstat (limited to 'Objects/object.c')
-rw-r--r-- | Objects/object.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Objects/object.c b/Objects/object.c index eea5531..ad31738 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); |