Kaydet (Commit) 5272fa9c authored tarafından Victor Stinner's avatar Victor Stinner

Fix _Py_DisplaySourceLine(), if PyTokenizer_FindEncodingFilename() fails, clear

the exception to not call open() with an exception set.
üst f326665f
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment