diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2005-12-18 05:29:30 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2005-12-18 05:29:30 (GMT) |
commit | db83eb3170ebdf55bd1c1add94838a9aefa8c00b (patch) | |
tree | 7920aeced87b5649ef95344d093c2d6fb6cf5b68 /Parser | |
parent | e7214a130b3fb1c4850a1e644b9e240087f6e982 (diff) | |
download | cpython-db83eb3170ebdf55bd1c1add94838a9aefa8c00b.zip cpython-db83eb3170ebdf55bd1c1add94838a9aefa8c00b.tar.gz cpython-db83eb3170ebdf55bd1c1add94838a9aefa8c00b.tar.bz2 |
Fix Bug #1378022, UTF-8 files with a leading BOM crashed the interpreter.
Needs backport.
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/tokenizer.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index 37e6c33..a79ea81 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -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; } |