From 79b06aaeb47c1d71a26a1f6c87d73457c7219755 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Tue, 27 Aug 2024 17:26:01 +0100 Subject: [PATCH] Update setuptools/command/easy_install.py Co-authored-by: Avasam --- setuptools/command/easy_install.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 3b63806c0a1..6ab83498787 100644 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1791,15 +1791,10 @@ def _first_line_re(): # Must match shutil._OnExcCallback def auto_chmod(func: Callable[..., _T], arg: str, exc: BaseException) -> _T: """shutils onexc callback to automatically call chmod for certain functions.""" - if os.name != 'nt': - raise OSError(f"Can't call auto_chmod on non-nt os {os.name!r}") from exc - supported_methods = {os.unlink, os.remove} - if func not in supported_methods: - raise ValueError( - f"Argument func is not one of {[method.__name__ for method in supported_methods]} (got: {func.__name__!r})" - ) from exc - chmod(arg, stat.S_IWRITE) - return func(arg) + if func in [os.unlink, os.remove] and os.name == 'nt': + chmod(arg, stat.S_IWRITE) + return func(arg) + raise exc def update_dist_caches(dist_path, fix_zipimporter_caches):