diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2005-10-02 01:48:49 +0000 |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2005-10-02 01:48:49 +0000 |
commit | 9b77c03453bdb9b3eb8cdfa1d2885653d56d770b (patch) | |
tree | 4678cb76865216f361034e502a5e911d4fc183f7 /Lib/test/test_coding.py | |
parent | e4f83c1d7c69e4141061aaf36063da0e229514ed (diff) | |
download | cpython-9b77c03453bdb9b3eb8cdfa1d2885653d56d770b.tar.gz |
- 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/test/test_coding.py')
-rw-r--r-- | Lib/test/test_coding.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_coding.py b/Lib/test/test_coding.py new file mode 100644 index 0000000000..aa7241d947 --- /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() |