diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2005-10-02 01:48:49 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2005-10-02 01:48:49 (GMT) |
commit | 40d37814166380b0fb585f818b446159cfbcec0f (patch) | |
tree | 80082c1713d2e7951b29b928e57ece73d3a4883b /Lib | |
parent | d45014b236f5a8707c104bb5b47bbb006e3bd4f3 (diff) | |
download | cpython-40d37814166380b0fb585f818b446159cfbcec0f.zip cpython-40d37814166380b0fb585f818b446159cfbcec0f.tar.gz cpython-40d37814166380b0fb585f818b446159cfbcec0f.tar.bz2 |
- Fix segfault with invalid coding.
- SF Bug #772896, unknown encoding results in MemoryError, which is not helpful
I will only backport the segfault fix. I'll let Anthony decide if he wants
the other changes backported. I will do the backport if asked.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/bad_coding.py | 1 | ||||
-rw-r--r-- | Lib/test/test_coding.py | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/bad_coding.py b/Lib/test/bad_coding.py new file mode 100644 index 0000000..971b0a8 --- /dev/null +++ b/Lib/test/bad_coding.py @@ -0,0 +1 @@ +# -*- coding: uft-8 -*- diff --git a/Lib/test/test_coding.py b/Lib/test/test_coding.py new file mode 100644 index 0000000..aa7241d --- /dev/null +++ b/Lib/test/test_coding.py @@ -0,0 +1,21 @@ + +import test.test_support, unittest +import os + +class CodingTest(unittest.TestCase): + def test_bad_coding(self): + module_name = 'bad_coding' + self.assertRaises(SyntaxError, __import__, 'test.' + module_name) + + path = os.path.dirname(__file__) + filename = os.path.join(path, module_name + '.py') + fp = open(filename) + text = fp.read() + fp.close() + self.assertRaises(SyntaxError, compile, text, filename, 'exec') + +def test_main(): + test.test_support.run_unittest(CodingTest) + +if __name__ == "__main__": + test_main() |