Skip to content

Commit 705216e

Browse files
committed
Branch on python version for shutil.rmtree
1 parent 79c2c04 commit 705216e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

weasel/util/filesystem.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import shutil
33
import stat
4+
import sys
45
import tempfile
56
import warnings
67
from contextlib import contextmanager
@@ -45,7 +46,10 @@ def force_remove(rmfunc, path, ex):
4546
rmfunc(path)
4647

4748
try:
48-
shutil.rmtree(str(d), onexc=force_remove)
49+
if sys.version_info >= (3, 12):
50+
shutil.rmtree(str(d), onexc=force_remove)
51+
else:
52+
shutil.rmtree(str(d), onerror=force_remove)
4953
except PermissionError as e:
5054
warnings.warn(Warnings.W801.format(dir=d, msg=e))
5155

0 commit comments

Comments
 (0)