From: Victor Stinner Date: Thu, 19 Dec 2013 12:39:32 +0000 (+0100) Subject: Fix _Py_DisplaySourceLine(), if PyTokenizer_FindEncodingFilename() fails, clear X-Git-Tag: v3.4.0b2~176 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5272fa9c5707b3cdcd6f49fdaf595b21bec6b2bd;p=thirdparty%2FPython%2Fcpython.git Fix _Py_DisplaySourceLine(), if PyTokenizer_FindEncodingFilename() fails, clear the exception to not call open() with an exception set. --- diff --git a/Python/traceback.c b/Python/traceback.c index e9169ce5e060..2ece192db90b 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) {