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 /Lib/test/test_pep263.py | |
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 'Lib/test/test_pep263.py')
-rw-r--r-- | Lib/test/test_pep263.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_pep263.py b/Lib/test/test_pep263.py index 9286467..4b60624 100644 --- a/Lib/test/test_pep263.py +++ b/Lib/test/test_pep263.py @@ -41,6 +41,24 @@ class PEP263Test(unittest.TestCase): # two bytes in common with the UTF-8 BOM self.assertRaises(SyntaxError, eval, '\xef\xbb\x20') + def test_error_message(self): + compile('# -*- coding: iso-8859-15 -*-\n', 'dummy', 'exec') + compile('\xef\xbb\xbf\n', 'dummy', 'exec') + compile('\xef\xbb\xbf# -*- coding: utf-8 -*-\n', 'dummy', 'exec') + with self.assertRaisesRegexp(SyntaxError, 'fake'): + compile('# -*- coding: fake -*-\n', 'dummy', 'exec') + with self.assertRaisesRegexp(SyntaxError, 'iso-8859-15'): + compile('\xef\xbb\xbf# -*- coding: iso-8859-15 -*-\n', + 'dummy', 'exec') + with self.assertRaisesRegexp(SyntaxError, 'BOM'): + compile('\xef\xbb\xbf# -*- coding: iso-8859-15 -*-\n', + 'dummy', 'exec') + with self.assertRaisesRegexp(SyntaxError, 'fake'): + compile('\xef\xbb\xbf# -*- coding: fake -*-\n', 'dummy', 'exec') + with self.assertRaisesRegexp(SyntaxError, 'BOM'): + compile('\xef\xbb\xbf# -*- coding: fake -*-\n', 'dummy', 'exec') + + def test_main(): test_support.run_unittest(PEP263Test) |