Skip to content

Commit 0a54cf1

Browse files
author
Victor Stinner
committed
Fix PyObject_Repr(): don't call PyUnicode_READY() if res is NULL
1 parent b37b174 commit 0a54cf1

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Objects/object.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,9 @@ PyObject_Repr(PyObject *v)
378378
return PyUnicode_FromFormat("<%s object at %p>",
379379
v->ob_type->tp_name, v);
380380
res = (*v->ob_type->tp_repr)(v);
381-
if (res != NULL && !PyUnicode_Check(res)) {
381+
if (res == NULL)
382+
return NULL;
383+
if (!PyUnicode_Check(res)) {
382384
PyErr_Format(PyExc_TypeError,
383385
"__repr__ returned non-string (type %.200s)",
384386
res->ob_type->tp_name);

0 commit comments

Comments
 (0)