mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Fix _Py_DisplaySourceLine(), if PyTokenizer_FindEncodingFilename() fails, clear
the exception to not call open() with an exception set.
This commit is contained in:
parent
f326665fe7
commit
5272fa9c57
1 changed files with 2 additions and 0 deletions
|
@ -264,6 +264,8 @@ _Py_DisplaySourceLine(PyObject *f, PyObject *filename, int lineno, int indent)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
found_encoding = PyTokenizer_FindEncodingFilename(fd, filename);
|
found_encoding = PyTokenizer_FindEncodingFilename(fd, filename);
|
||||||
|
if (found_encoding == NULL)
|
||||||
|
PyErr_Clear();
|
||||||
encoding = (found_encoding != NULL) ? found_encoding : "utf-8";
|
encoding = (found_encoding != NULL) ? found_encoding : "utf-8";
|
||||||
/* Reset position */
|
/* Reset position */
|
||||||
if (lseek(fd, 0, SEEK_SET) == (off_t)-1) {
|
if (lseek(fd, 0, SEEK_SET) == (off_t)-1) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue