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))