diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-06-09 13:51:52 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-06-09 13:51:52 (GMT) |
commit | 3af14aaba5e5df6e1bbe67f037bef1b1789209ca (patch) | |
tree | d38d289f62eb0439442e6282cc0249d627640cc0 /Parser | |
parent | c1f58394120eded222ed76ae930944e6403e6b3d (diff) | |
download | cpython-3af14aaba5e5df6e1bbe67f037bef1b1789209ca.zip cpython-3af14aaba5e5df6e1bbe67f037bef1b1789209ca.tar.gz cpython-3af14aaba5e5df6e1bbe67f037bef1b1789209ca.tar.bz2 |
Issue #18038: SyntaxError raised during compilation sources with illegal
encoding now always contains an encoding name.
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/tokenizer.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index 93a4a5c..7fe384b 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -291,20 +291,20 @@ check_coding_spec(const char* line, Py_ssize_t size, struct tok_state *tok, tok->encoding = cs; tok->decoding_state = STATE_NORMAL; } - else + else { + PyErr_Format(PyExc_SyntaxError, + "encoding problem: %s", cs); PyMem_FREE(cs); + } } } else { /* then, compare cs with BOM */ r = (strcmp(tok->encoding, cs) == 0); + if (!r) + PyErr_Format(PyExc_SyntaxError, + "encoding problem: %s with BOM", cs); PyMem_FREE(cs); } } - if (!r) { - cs = tok->encoding; - if (!cs) - cs = "with BOM"; - PyErr_Format(PyExc_SyntaxError, "encoding problem: %s", cs); - } return r; } |