summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-12-09 02:10:08 +0100
committerVictor Stinner <victor.stinner@gmail.com>2013-12-09 02:10:08 +0100
commit88f29f787daaf77dfe602476cb4707a593709945 (patch)
treea9565ab1cd72f39bde2ce35ce53a9dd847813cf2 /Python/pythonrun.c
parent506ce02c2bec970b4ef24dc591a525ffa27941a2 (diff)
downloadcpython-88f29f787daaf77dfe602476cb4707a593709945.tar.gz
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 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;
}