]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
A test was not guaranteeing cleanup in the face of an exception.
authorBrett Cannon <bcannon@gmail.com>
Sat, 15 May 2010 22:20:16 +0000 (22:20 +0000)
committerBrett Cannon <bcannon@gmail.com>
Sat, 15 May 2010 22:20:16 +0000 (22:20 +0000)
Lib/test/test_import.py

index 0a21e182eb78b94bc836fcd7dbf5bcc47128a050..2ea673637a8e5af0031f482baa0c737e68623ea4 100644 (file)
@@ -163,13 +163,14 @@ class ImportTests(unittest.TestCase):
         # Need to be able to load from current dir.
         sys.path.append('')
 
-        # This used to crash.
-        exec('import ' + module)
-
-        # Cleanup.
-        del sys.path[-1]
-        unlink(filename + 'c')
-        unlink(filename + 'o')
+        try:
+            # This used to crash.
+            exec('import ' + module)
+        finally:
+            # Cleanup.
+            del sys.path[-1]
+            unlink(filename + 'c')
+            unlink(filename + 'o')
 
     def test_failing_import_sticks(self):
         source = TESTFN + ".py"