mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-04 04:10:20 +03:00
Revert "make_tempdir: attempt to fix removing readonly files on Windows"
This reverts commit 2bcdcbdbaf
.
This commit is contained in:
parent
2bcdcbdbaf
commit
35e3d8c884
|
@ -1032,14 +1032,6 @@ def working_dir(path: Union[str, Path]) -> Iterator[Path]:
|
||||||
os.chdir(str(prev_cwd))
|
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
|
@contextmanager
|
||||||
def make_tempdir() -> Generator[Path, None, None]:
|
def make_tempdir() -> Generator[Path, None, None]:
|
||||||
"""Execute a block in a temporary directory and remove the directory and
|
"""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())
|
d = Path(tempfile.mkdtemp())
|
||||||
yield d
|
yield d
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(str(d), onerror=_rm_readonly)
|
shutil.rmtree(str(d))
|
||||||
except PermissionError as e:
|
except PermissionError as e:
|
||||||
warnings.warn(Warnings.W091.format(dir=d, msg=e))
|
warnings.warn(Warnings.W091.format(dir=d, msg=e))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user