Skip to content

Commit 0f1afb1

Browse files
committed
test_module_with_large_stack(): This failed when Python was run with -O,
trying to delete a .pyc file that didn't exist (it needed to delete .pyo then).
1 parent 0672712 commit 0f1afb1

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Lib/test/test_import.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def test_module_with_large_stack(module):
8888
f.write(']')
8989
f.close()
9090

91-
# compile & remove .py file, we only need .pyc
91+
# compile & remove .py file, we only need .pyc (or .pyo)
9292
f = open(filename, 'r')
9393
py_compile.compile(filename)
9494
f.close()
@@ -102,6 +102,9 @@ def test_module_with_large_stack(module):
102102

103103
# cleanup
104104
del sys.path[-1]
105-
os.unlink(module + '.pyc')
105+
for ext in '.pyc', '.pyo':
106+
fname = module + ext
107+
if os.path.exists(fname):
108+
os.unlink(fname)
106109

107110
test_module_with_large_stack('longlist')

0 commit comments

Comments
 (0)