diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-12-09 02:10:08 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-12-09 02:10:08 +0100 |
commit | 88f29f787daaf77dfe602476cb4707a593709945 (patch) | |
tree | a9565ab1cd72f39bde2ce35ce53a9dd847813cf2 /Python/pythonrun.c | |
parent | 506ce02c2bec970b4ef24dc591a525ffa27941a2 (diff) | |
download | cpython-88f29f787daaf77dfe602476cb4707a593709945.tar.gz |
Issue #19817: Fix print_exception(), clear the exception on error
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index ccf82af36b..97daecc205 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -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; } |