diff options
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') + |
