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