From 35e3d8c884709b30a72d3d71f59b5c6ae1d32cf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danie=CC=88l=20de=20Kok?= Date: Wed, 25 Jan 2023 11:32:28 +0100 Subject: [PATCH] Revert "make_tempdir: attempt to fix removing readonly files on Windows" This reverts commit 2bcdcbdbaf7f830ed935adaea81653ed8a82c568. --- spacy/util.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/spacy/util.py b/spacy/util.py index 024e1df26..8bf8fb1b0 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -1032,14 +1032,6 @@ def working_dir(path: Union[str, Path]) -> Iterator[Path]: os.chdir(str(prev_cwd)) -def _rm_readonly(func, path, excinfo): - if not os.access(path, os.W_OK): - os.chmod(path, os.stat.S_IWRITE) - func(path) - else: - raise - - @contextmanager def make_tempdir() -> Generator[Path, None, None]: """Execute a block in a temporary directory and remove the directory and @@ -1050,7 +1042,7 @@ def make_tempdir() -> Generator[Path, None, None]: d = Path(tempfile.mkdtemp()) yield d try: - shutil.rmtree(str(d), onerror=_rm_readonly) + shutil.rmtree(str(d)) except PermissionError as e: warnings.warn(Warnings.W091.format(dir=d, msg=e))