diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-06-09 13:54:56 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-06-09 13:54:56 (GMT) |
commit | 729ad5cf561ba644322952b79051269f07bb1ec0 (patch) | |
tree | 22c50dbce59e4c048a6752db5ed4b28cf2e99994 /Parser | |
parent | c49805e96782e4e0ec4fe6c8cf0172d435b328ec (diff) | |
download | cpython-729ad5cf561ba644322952b79051269f07bb1ec0.zip cpython-729ad5cf561ba644322952b79051269f07bb1ec0.tar.gz cpython-729ad5cf561ba644322952b79051269f07bb1ec0.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 ee6313b..46cf9b2 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -277,8 +277,11 @@ check_coding_spec(const char* line, Py_ssize_t size, struct tok_state *tok, tok->encoding = cs; tok->decoding_state = -1; } - else + else { + PyErr_Format(PyExc_SyntaxError, + "encoding problem: %s", cs); PyMem_FREE(cs); + } #else /* Without Unicode support, we cannot process the coding spec. Since there @@ -289,15 +292,12 @@ check_coding_spec(const char* line, Py_ssize_t size, struct tok_state *tok, } } 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; } |