From: Victor Stinner Date: Fri, 17 Jun 2011 11:25:53 +0000 (+0200) Subject: Issue #12333: close files before removing the directory X-Git-Tag: v3.3.0a1~2108 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0f270b2c37efd2c9600d9f8648918d9b3479dd94;p=thirdparty%2FPython%2Fcpython.git Issue #12333: close files before removing the directory packaging.tests.support.TempdirManager: rmtree() fails on Windows if there are still open files in the directory. --- diff --git a/Lib/packaging/tests/support.py b/Lib/packaging/tests/support.py index 47ce513d185d..8394f54607c8 100644 --- a/Lib/packaging/tests/support.py +++ b/Lib/packaging/tests/support.py @@ -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):