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 /Lib/test | |
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 'Lib/test')
-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 598d980..1290bc7 100644 --- a/Lib/test/test_pep263.py +++ b/Lib/test/test_pep263.py @@ -55,6 +55,24 @@ class PEP263Test(unittest.TestCase): # two bytes in common with the UTF-8 BOM self.assertRaises(SyntaxError, eval, b'\xef\xbb\x20') + def test_error_message(self): + compile(b'# -*- coding: iso-8859-15 -*-\n', 'dummy', 'exec') + compile(b'\xef\xbb\xbf\n', 'dummy', 'exec') + compile(b'\xef\xbb\xbf# -*- coding: utf-8 -*-\n', 'dummy', 'exec') + with self.assertRaisesRegexp(SyntaxError, 'fake'): + compile(b'# -*- coding: fake -*-\n', 'dummy', 'exec') + with self.assertRaisesRegexp(SyntaxError, 'iso-8859-15'): + compile(b'\xef\xbb\xbf# -*- coding: iso-8859-15 -*-\n', + 'dummy', 'exec') + with self.assertRaisesRegexp(SyntaxError, 'BOM'): + compile(b'\xef\xbb\xbf# -*- coding: iso-8859-15 -*-\n', + 'dummy', 'exec') + with self.assertRaisesRegexp(SyntaxError, 'fake'): + compile(b'\xef\xbb\xbf# -*- coding: fake -*-\n', 'dummy', 'exec') + with self.assertRaisesRegexp(SyntaxError, 'BOM'): + compile(b'\xef\xbb\xbf# -*- coding: fake -*-\n', 'dummy', 'exec') + + def test_main(): support.run_unittest(PEP263Test) |