]> granicus.if.org Git - python/commitdiff
Issue #18408: Fix show_warning(), clear also the exception raised by
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 15 Jul 2013 23:54:37 +0000 (01:54 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 15 Jul 2013 23:54:37 +0000 (01:54 +0200)
_Py_DisplaySourceLine()

For example, _PyGC_DumpShutdownStats() calls PyErr_WarnExplicitFormat() while
the import machinery does not work anymore, _Py_DisplaySourceLine() fails when
trying to import the io module.

Python/_warnings.c

index 03e0c4545ae3947f3e131bfc599ed15f0d76f826..f93ede2e2f5546a52133ad8cde0c4f3daf42ce2d 100644 (file)
@@ -283,9 +283,9 @@ show_warning(PyObject *filename, int lineno, PyObject *text, PyObject
         PyFile_WriteString(source_line_str, f_stderr);
         PyFile_WriteString("\n", f_stderr);
     }
-    else
-        if (_Py_DisplaySourceLine(f_stderr, filename, lineno, 2) < 0)
-                return;
+    else {
+        _Py_DisplaySourceLine(f_stderr, filename, lineno, 2);
+    }
     PyErr_Clear();
 }