*** test_pep263.py.orig Tue Oct 12 22:29:39 2004 --- test_pep263.py Wed Mar 16 10:43:53 2005 *************** *** 3,8 **** --- 3,9 ---- import unittest from test import test_support + import os class PEP263Test(unittest.TestCase): *************** *** 16,23 **** '\\\xd0\x9f' ) def test_main(): ! test_support.run_unittest(PEP263Test) if __name__=="__main__": test_main() --- 17,57 ---- '\\\xd0\x9f' ) + # The following two tests will trigger an assert with a debug build of Python 2.4. + # With a release build, they will overflow a buffer, which should trigger + # a segfault/access violation. The overflow is in tokenizer.c's handling of encoded + # files, so both tests use execfile, which always compiles the given file (no .pyc file + # is created). + + class EvilEncodingTest(unittest.TestCase): + def setUp(self): + self.savedir = os.getcwd() + os.chdir(os.path.dirname(__file__)) + import evilascii + self.n = evilascii.n + self.char = evilascii.char + def findEvilAscii(name): + if name == "evilascii": + return evilascii.getregentry() + return None + import codecs + codecs.register(findEvilAscii) + def tearDown(self): + os.chdir(self.savedir) + def test_evilencoding(self): + namespace = {} + execfile("pep263_evilencoding.py", namespace) + self.assertEqual(namespace["x"], self.n*self.char) + + class LongLineTest(unittest.TestCase): + def test_longline(self): + testdir = os.path.dirname(__file__) + namespace = {} + execfile(os.path.join(testdir, "pep263_longline.py"), namespace) + self.assertEqual(len(namespace["_Application_vtables_"]), 371) + def test_main(): ! test_support.run_unittest(PEP263Test, EvilEncodingTest, LongLineTest) if __name__=="__main__": test_main()