]> granicus.if.org Git - python/commitdiff
Issue #18408: Fix _Py_DisplaySourceLine()
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 15 Jul 2013 22:32:14 +0000 (00:32 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 15 Jul 2013 22:32:14 +0000 (00:32 +0200)
Report _Py_FindSourceFile() error, so the error is cleared;
and clear io.open(filename) exception on failure.

Python/traceback.c

index c56b23f6cca5b7b1695d3614c59eb1b9b378788e..8130d4bcec5d85bd8adb0f4b6fd77dc21abcfa7e 100644 (file)
@@ -246,10 +246,12 @@ _Py_DisplaySourceLine(PyObject *f, PyObject *filename, int lineno, int indent)
     binary = _PyObject_CallMethodId(io, &PyId_open, "Os", filename, "rb");
 
     if (binary == NULL) {
+        PyErr_Clear();
+
         binary = _Py_FindSourceFile(filename, buf, sizeof(buf), io);
         if (binary == NULL) {
             Py_DECREF(io);
-            return 0;
+            return -1;
         }
     }