diff options
author | Brett Cannon <bcannon@gmail.com> | 2008-10-17 03:38:50 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2008-10-17 03:38:50 (GMT) |
commit | da780432378e6298463889557ab43e0c156758cd (patch) | |
tree | dc622a9b62874851f90abc45524d3d2653cab9ba /Lib/test/test_pep3120.py | |
parent | 9e9dcd6d4225faa6a8b19120f009e0253d16ab92 (diff) | |
download | cpython-da780432378e6298463889557ab43e0c156758cd.zip cpython-da780432378e6298463889557ab43e0c156758cd.tar.gz cpython-da780432378e6298463889557ab43e0c156758cd.tar.bz2 |
Latin-1 source code was not being properly decoded when passed through
compile(). This was due to left-over special-casing before UTF-8 became the
default source encoding.
Closes issue #3574. Thanks to Victor Stinner for help with the patch.
Diffstat (limited to 'Lib/test/test_pep3120.py')
-rw-r--r-- | Lib/test/test_pep3120.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Lib/test/test_pep3120.py b/Lib/test/test_pep3120.py index 3bb30ca..81d15bc 100644 --- a/Lib/test/test_pep3120.py +++ b/Lib/test/test_pep3120.py @@ -23,8 +23,24 @@ class PEP3120Test(unittest.TestCase): else: self.fail("expected exception didn't occur") + +class BuiltinCompileTests(unittest.TestCase): + + # Issue 3574. + def test_latin1(self): + # Allow compile() to read Latin-1 source. + source_code = '# coding: Latin-1\nu = "Ç"\n'.encode("Latin-1") + try: + code = compile(source_code, '<dummy>', 'exec') + except SyntaxError: + self.fail("compile() cannot handle Latin-1 source") + ns = {} + exec(code, ns) + self.assertEqual('Ç', ns['u']) + + def test_main(): - support.run_unittest(PEP3120Test) + support.run_unittest(PEP3120Test, BuiltinCompileTests) if __name__=="__main__": test_main() |