[Python-checkins] cpython: Issue #19817: Fix print_exception(), clear the exception on error

victor.stinner python-checkins at python.org
Mon Dec 9 12:40:37 CET 2013


http://hg.python.org/cpython/rev/45442f2a2494
changeset:   87849:45442f2a2494
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Mon Dec 09 02:10:08 2013 +0100
summary:
  Issue #19817: Fix print_exception(), clear the exception on error

files:
  Python/pythonrun.c |  8 +++++---
  1 files changed, 5 insertions(+), 3 deletions(-)


diff --git a/Python/pythonrun.c b/Python/pythonrun.c
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1888,9 +1888,11 @@
     _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;
     }
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list