diff -r 4cfc19f667aa Lib/test/test_pep263.py --- a/Lib/test/test_pep263.py Wed Feb 10 05:44:01 2016 +0000 +++ b/Lib/test/test_pep263.py Wed Feb 10 09:52:39 2016 +0200 @@ -63,6 +63,12 @@ class PEP263Test(unittest.TestCase): 'codec did not return a unicode'): from test import bad_coding3 + def test_bad_utf8(self): + with self.assertRaisesRegexp(SyntaxError, 'utf8'): + compile('# -*- coding: utf8 -*-\n#\xc3', 'dummy', 'exec') + with self.assertRaisesRegexp(SyntaxError, 'utf8'): + compile('# -*- coding: utf-8 -*-\n#\xc3', 'dummy', 'exec') + def test_main(): test_support.run_unittest(PEP263Test) diff -r 4cfc19f667aa Parser/tokenizer.c --- a/Parser/tokenizer.c Wed Feb 10 05:44:01 2016 +0000 +++ b/Parser/tokenizer.c Wed Feb 10 09:52:39 2016 +0200 @@ -285,8 +285,7 @@ check_coding_spec(const char* line, Py_s tok->read_coding_spec = 1; if (tok->encoding == NULL) { assert(tok->decoding_state == 1); /* raw */ - if (strcmp(cs, "utf-8") == 0 || - strcmp(cs, "iso-8859-1") == 0) { + if (strcmp(cs, "iso-8859-1") == 0) { tok->encoding = cs; } else { #ifdef Py_USING_UNICODE