diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-12-19 13:39:32 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-12-19 13:39:32 +0100 |
commit | b283473939e00f8ee3b773edf64b4c0098ff2e38 (patch) | |
tree | 0683a6cdba9a5786cd545de20b34e1bc091020bb /Python/traceback.c | |
parent | 85a977b1833e4d1b3af28218ebffcafa17558a62 (diff) | |
download | cpython-b283473939e00f8ee3b773edf64b4c0098ff2e38.tar.gz |
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.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Python/traceback.c b/Python/traceback.c index e9169ce5e0..2ece192db9 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) { |