Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 52ce3b0

Browse files
committed
Issue #19817: Fix print_exception(), clear the exception on error
1 parent 383bff4 commit 52ce3b0

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

Python/pythonrun.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1888,9 +1888,11 @@ print_exception(PyObject *f, PyObject *value)
18881888
_Py_IDENTIFIER(print_file_and_line);
18891889

18901890
if (!PyExceptionInstance_Check(value)) {
1891-
PyFile_WriteString("TypeError: print_exception(): Exception expected for value, ", f);
1892-
PyFile_WriteString(Py_TYPE(value)->tp_name, f);
1893-
PyFile_WriteString(" found\n", f);
1891+
err = PyFile_WriteString("TypeError: print_exception(): Exception expected for value, ", f);
1892+
err += PyFile_WriteString(Py_TYPE(value)->tp_name, f);
1893+
err += PyFile_WriteString(" found\n", f);
1894+
if (err)
1895+
PyErr_Clear();
18941896
return;
18951897
}
18961898

0 commit comments

Comments
 (0)