diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2002-06-14 01:07:39 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2002-06-14 01:07:39 (GMT) |
commit | 7fdcb411312db260e77f291b4e8a865aa61b7c6a (patch) | |
tree | 6ebdfc0e3aa5b23ee5ff43ab4dbb99a9c52119d1 /Lib/test/test_import.py | |
parent | 1f68fc7fa5048e0576ff26436012765f4a8fa3d4 (diff) | |
download | cpython-7fdcb411312db260e77f291b4e8a865aa61b7c6a.zip cpython-7fdcb411312db260e77f291b4e8a865aa61b7c6a.tar.gz cpython-7fdcb411312db260e77f291b4e8a865aa61b7c6a.tar.bz2 |
Fix SF bug # 561858 Assertion with very long lists
Write 4 bytes for co_stacksize, etc. to prevent writing out
bad .pyc files which can cause a crash when read back in.
Diffstat (limited to 'Lib/test/test_import.py')
-rw-r--r-- | Lib/test/test_import.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py index 933a364..1246822 100644 --- a/Lib/test/test_import.py +++ b/Lib/test/test_import.py @@ -3,6 +3,7 @@ from test_support import TESTFN, TestFailed import os import random import sys +import py_compile # Brief digression to test that import is case-sensitive: if we got this # far, we know for sure that "random" exists. @@ -74,3 +75,33 @@ finally: import imp x = imp.find_module("os") os = imp.load_module("os", *x) + +def test_module_with_large_stack(module): + # create module w/list of 65000 elements to test bug #561858 + filename = module + '.py' + + # create a file with a list of 65000 elements + f = open(filename, 'w+') + f.write('d = [\n') + for i in range(65000): + f.write('"",\n') + f.write(']') + f.close() + + # compile & remove .py file, we only need .pyc + f = open(filename, 'r') + py_compile.compile(filename) + os.unlink(filename) + + # need to be able to load from current dir + sys.path.append('') + + # this used to crash + exec 'import ' + module + + # cleanup + del sys.path[-1] + os.unlink(module + '.pyc') + +test_module_with_large_stack('longlist') + |