Fix Bug #1378022, UTF-8 files with a leading BOM crashed the interpreter.

Needs backport.
This commit is contained in:
Neal Norwitz 2005-12-18 05:29:30 +00:00
parent e7214a130b
commit db83eb3170
5 changed files with 19 additions and 2 deletions

View file

@ -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;
}