From 0f1afb1df3c1150cc2906ed85b2f52f89f51f670 Mon Sep 17 00:00:00 2001 From: Tim Peters Date: Sat, 15 Jun 2002 05:14:05 +0000 Subject: [PATCH] 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). --- Lib/test/test_import.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py index 9342812da32..1ddd13e6b2e 100644 --- a/Lib/test/test_import.py +++ b/Lib/test/test_import.py @@ -88,7 +88,7 @@ def test_module_with_large_stack(module): f.write(']') f.close() - # compile & remove .py file, we only need .pyc + # compile & remove .py file, we only need .pyc (or .pyo) f = open(filename, 'r') py_compile.compile(filename) f.close() @@ -102,6 +102,9 @@ def test_module_with_large_stack(module): # cleanup del sys.path[-1] - os.unlink(module + '.pyc') + for ext in '.pyc', '.pyo': + fname = module + ext + if os.path.exists(fname): + os.unlink(fname) test_module_with_large_stack('longlist')