summaryrefslogtreecommitdiffstats
path: root/Python/traceback.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-12-19 12:39:32 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-12-19 12:39:32 (GMT)
commit5272fa9c5707b3cdcd6f49fdaf595b21bec6b2bd (patch)
treea67e2267c4c178ff38947bdbf2ed08c41263cb22 /Python/traceback.c
parentf326665fe7d89df3617b142749c195187ba56d0e (diff)
downloadcpython-5272fa9c5707b3cdcd6f49fdaf595b21bec6b2bd.zip
cpython-5272fa9c5707b3cdcd6f49fdaf595b21bec6b2bd.tar.gz
cpython-5272fa9c5707b3cdcd6f49fdaf595b21bec6b2bd.tar.bz2
Fix _Py_DisplaySourceLine(), if PyTokenizer_FindEncodingFilename() fails, clear
the exception to not call open() with an exception set.
Diffstat (limited to 'Python/traceback.c')
-rw-r--r--Python/traceback.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/Python/traceback.c b/Python/traceback.c
index e9169ce..2ece192 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -264,6 +264,8 @@ _Py_DisplaySourceLine(PyObject *f, PyObject *filename, int lineno, int indent)
return 0;
}
found_encoding = PyTokenizer_FindEncodingFilename(fd, filename);
+ if (found_encoding == NULL)
+ PyErr_Clear();
encoding = (found_encoding != NULL) ? found_encoding : "utf-8";
/* Reset position */
if (lseek(fd, 0, SEEK_SET) == (off_t)-1) {