From: Victor Stinner Date: Mon, 9 Dec 2013 01:10:08 +0000 (+0100) Subject: Issue #19817: Fix print_exception(), clear the exception on error X-Git-Tag: v3.4.0b2~284 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52ce3b04d094b568c303968b2273e2322b422e38;p=thirdparty%2FPython%2Fcpython.git Issue #19817: Fix print_exception(), clear the exception on error --- diff --git a/Python/pythonrun.c b/Python/pythonrun.c index ccf82af36bad..97daecc20504 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; }