From 76d94b31f239f419fabfe6fd27bb039175a6bee5 Mon Sep 17 00:00:00 2001 From: Adriane Boyd Date: Fri, 22 Sep 2023 16:58:33 +0200 Subject: [PATCH] Branch on python 3.12+ shutil.rmtree in make_tempdir --- spacy/util.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spacy/util.py b/spacy/util.py index c5c57d67d..8464e411f 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -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))