diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2007-11-15 23:19:43 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2007-11-15 23:19:43 (GMT) |
commit | 65f9aced6ebecf418a91d273e314e40bd153e113 (patch) | |
tree | 2acf8d49fdd15697e8de8c50cba3e61678a15fa7 /Lib/test | |
parent | c05f42a8a76800fc5a6a8a019710351dfd58dec2 (diff) | |
download | cpython-65f9aced6ebecf418a91d273e314e40bd153e113.zip cpython-65f9aced6ebecf418a91d273e314e40bd153e113.tar.gz cpython-65f9aced6ebecf418a91d273e314e40bd153e113.tar.bz2 |
Correction for issue1134: all source files with a coding spec, except latin-1
and utf-8, crashed when parsing a multiline string, or a line longer that 512
columns.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_coding.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/Lib/test/test_coding.py b/Lib/test/test_coding.py index 4d4b3f9..0ff1bdf 100644 --- a/Lib/test/test_coding.py +++ b/Lib/test/test_coding.py @@ -1,6 +1,6 @@ import test.test_support, unittest -import os +import os, sys class CodingTest(unittest.TestCase): def test_bad_coding(self): @@ -26,6 +26,26 @@ class CodingTest(unittest.TestCase): exec('# coding: cp949\na = 5\n', d) self.assertEqual(d['a'], 5) + def test_file_parse(self): + # issue1134: all encodings outside latin-1 and utf-8 fail on + # multiline strings and long lines (>512 columns) + sys.path.insert(0, ".") + filename = test.test_support.TESTFN+".py" + f = open(filename, "w") + try: + f.write("# -*- coding: cp1252 -*-\n") + f.write("'''A short string\n") + f.write("'''\n") + f.write("'A very long string %s'\n" % ("X" * 1000)) + f.close() + + __import__(test.test_support.TESTFN) + finally: + f.close() + os.remove(test.test_support.TESTFN+".py") + os.remove(test.test_support.TESTFN+".pyc") + sys.path.pop(0) + def test_main(): test.test_support.run_unittest(CodingTest) |