diff -r 85c04fdaa404 Parser/tokenizer.c --- a/Parser/tokenizer.c Wed May 22 15:28:30 2013 +0300 +++ b/Parser/tokenizer.c Thu May 23 07:23:36 2013 +0300 @@ -277,8 +277,10 @@ 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 +291,11 @@ } } else { /* then, compare cs with BOM */ r = (strcmp(tok->encoding, cs) == 0); + if (!r) + PyErr_Format(PyExc_SyntaxError, "encoding problem: with BOM"); PyMem_FREE(cs); } } - if (!r) { - cs = tok->encoding; - if (!cs) - cs = "with BOM"; - PyErr_Format(PyExc_SyntaxError, "encoding problem: %s", cs); - } return r; }