Branch on python 3.12+ shutil.rmtree in make_tempdir

This commit is contained in:
Adriane Boyd 2023-09-22 16:58:33 +02:00
parent 1adf79414e
commit 76d94b31f2

View File

@ -1068,7 +1068,10 @@ def make_tempdir() -> Generator[Path, None, None]:
rmfunc(path)
try:
shutil.rmtree(str(d), onerror=force_remove)
if sys.version_info >= (3, 12):
shutil.rmtree(str(d), onexc=force_remove)
else:
shutil.rmtree(str(d), onerror=force_remove)
except PermissionError as e:
warnings.warn(Warnings.W091.format(dir=d, msg=e))