mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
Issue #19817: Fix print_exception(), clear the exception on error
This commit is contained in:
parent
383bff4d74
commit
52ce3b04d0
1 changed files with 5 additions and 3 deletions
|
@ -1888,9 +1888,11 @@ print_exception(PyObject *f, PyObject *value)
|
|||
_Py_IDENTIFIER(print_file_and_line);
|
||||
|
||||
if (!PyExceptionInstance_Check(value)) {
|
||||
PyFile_WriteString("TypeError: print_exception(): Exception expected for value, ", f);
|
||||
PyFile_WriteString(Py_TYPE(value)->tp_name, f);
|
||||
PyFile_WriteString(" found\n", f);
|
||||
err = PyFile_WriteString("TypeError: print_exception(): Exception expected for value, ", f);
|
||||
err += PyFile_WriteString(Py_TYPE(value)->tp_name, f);
|
||||
err += PyFile_WriteString(" found\n", f);
|
||||
if (err)
|
||||
PyErr_Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue