From 88f29f787daaf77dfe602476cb4707a593709945 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 9 Dec 2013 02:10:08 +0100 Subject: Issue #19817: Fix print_exception(), clear the exception on error --- Python/pythonrun.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Python/pythonrun.c') 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; } -- cgit v1.2.1