mirror of
https://github.com/python/cpython.git
synced 2025-07-23 19:25:40 +00:00
Fix Bug #1378022, UTF-8 files with a leading BOM crashed the interpreter.
Needs backport.
This commit is contained in:
parent
e7214a130b
commit
db83eb3170
5 changed files with 19 additions and 2 deletions
|
@ -292,6 +292,12 @@ check_coding_spec(const char* line, int size, struct tok_state *tok,
|
|||
PyMem_DEL(cs);
|
||||
}
|
||||
}
|
||||
if (!r) {
|
||||
cs = tok->encoding;
|
||||
if (!cs)
|
||||
cs = "with BOM";
|
||||
PyErr_Format(PyExc_SyntaxError, "encoding problem: %s", cs);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue