summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-08-02 17:23:11 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-08-02 17:23:11 (GMT)
commitd342c62961b04b3d08b8776615c3d32a38268a13 (patch)
tree6ba4c873fbcb7a8464052b0c9e85f0f5e67e800d /Lib
parent044bb4d22a20a172edc58dd7eed5f72428d2cc16 (diff)
downloadcpython-d342c62961b04b3d08b8776615c3d32a38268a13.zip
cpython-d342c62961b04b3d08b8776615c3d32a38268a13.tar.gz
cpython-d342c62961b04b3d08b8776615c3d32a38268a13.tar.bz2
This test failed under python -O.
rewrite_file(): Delete both .pyc and .pyo leftovers, and explicitly close the new source file after writing to it.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_pkgimport.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/test/test_pkgimport.py b/Lib/test/test_pkgimport.py
index 53e80b0..bff4044 100644
--- a/Lib/test/test_pkgimport.py
+++ b/Lib/test/test_pkgimport.py
@@ -36,9 +36,13 @@ class TestImport(unittest.TestCase):
self.remove_modules()
def rewrite_file(self, contents):
- compiled_path = self.module_path + 'c'
- if os.path.exists(compiled_path): os.remove(compiled_path)
- open(self.module_path, 'w').write(contents)
+ for extension in "co":
+ compiled_path = self.module_path + extension
+ if os.path.exists(compiled_path):
+ os.remove(compiled_path)
+ f = open(self.module_path, 'w')
+ f.write(contents)
+ f.close()
def test_package_import__semantics(self):