]> granicus.if.org Git - python/commitdiff
Issue #12333: close files before removing the directory
authorVictor Stinner <victor.stinner@haypocalc.com>
Fri, 17 Jun 2011 11:25:53 +0000 (13:25 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Fri, 17 Jun 2011 11:25:53 +0000 (13:25 +0200)
packaging.tests.support.TempdirManager: rmtree() fails on Windows if there are
still open files in the directory.

Lib/packaging/tests/support.py

index 47ce513d185def13fca83f358ac0b9db19c98b68..8394f54607c89722d420e120b9a4ac0d11b1358f 100644 (file)
@@ -126,13 +126,12 @@ class TempdirManager:
         self._files = []
 
     def tearDown(self):
-        os.chdir(self._olddir)
-        shutil.rmtree(self._basetempdir)
-
         for handle, name in self._files:
             handle.close()
             unlink(name)
 
+        os.chdir(self._olddir)
+        shutil.rmtree(self._basetempdir)
         super(TempdirManager, self).tearDown()
 
     def mktempfile(self):