summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-12-09 01:10:08 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-12-09 01:10:08 (GMT)
commit52ce3b04d094b568c303968b2273e2322b422e38 (patch)
treeed2a529ab7394e896a93d5e0aaa4d9832f9597c4 /Python/pythonrun.c
parent383bff4d740c2ee154c230f62fc28f5baa09fa10 (diff)
downloadcpython-52ce3b04d094b568c303968b2273e2322b422e38.zip
cpython-52ce3b04d094b568c303968b2273e2322b422e38.tar.gz
cpython-52ce3b04d094b568c303968b2273e2322b422e38.tar.bz2
Issue #19817: Fix print_exception(), clear the exception on error
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index ccf82af..97daecc 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;
}