From: Brett Cannon Date: Sat, 15 May 2010 22:20:16 +0000 (+0000) Subject: A test was not guaranteeing cleanup in the face of an exception. X-Git-Tag: v3.2a1~796 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=93220d0df11a5cbdc460db8e0e6b4d6967e022eb;p=thirdparty%2FPython%2Fcpython.git A test was not guaranteeing cleanup in the face of an exception. --- diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py index 0a21e182eb78..2ea673637a8e 100644 --- a/Lib/test/test_import.py +++ b/Lib/test/test_import.py @@ -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"