Skip to content

Commit d7eecfc

Browse files
committed
The niggling errors cleaning directories on Windows 7 seem to be fixed by this function which was only meant to help diagnose the problem. A heisenbug!
1 parent 444fd0e commit d7eecfc

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

test/test_farm.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,19 @@ def clean(self, cleandir):
296296
"""Clean `cleandir` by removing it and all its children completely."""
297297
if os.path.exists(cleandir):
298298
# rmtree gives mysterious failures on Win7, so use an onerror
299-
# function that simply retries the operation. Why that helps, I
300-
# have no idea.
301-
shutil.rmtree(cleandir, onerror=lambda fn, path, exc: fn(path))
299+
# function that tries to help diagnose the problem. Somehow, just
300+
# having a function that prints and raises keeps the error from
301+
# happening??
302+
shutil.rmtree(cleandir, onerror=self.rmtree_err)
303+
304+
def rmtree_err(self, fn, path, exc):
305+
"""A stupid error handler that prints and raises.
306+
307+
Somehow, this fixes the problem it was meant to diagnose.
308+
309+
"""
310+
print("Couldn't %r on %r due to %s" % (fn, path, exc))
311+
raise exc
302312

303313

304314
def main(): # pragma: no cover

0 commit comments

Comments
 (0)