Skip to content

Commit f725dab

Browse files
committed
Issue #18408: Fix dict_repr(), don't call PyObject_Repr() with an exception set
PyObject_Repr() can removes the current exception. For example, module_repr() calls PyErr_Clear() if calling loader.module_repr(mod) failed.
1 parent 3ede318 commit f725dab

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Objects/dictobject.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,9 @@ dict_repr(PyDictObject *mp)
14431443
Py_INCREF(value);
14441444
s = PyObject_Repr(key);
14451445
PyUnicode_Append(&s, colon);
1446+
if (s == NULL)
1447+
goto Done;
1448+
14461449
PyUnicode_AppendAndDel(&s, PyObject_Repr(value));
14471450
Py_DECREF(key);
14481451
Py_DECREF(value);

0 commit comments

Comments
 (0)