Mercurial > public > mercurial-scm > hg-stable
diff setup.py @ 49318:050dc8730858
py3: catch specific OSError subclasses instead of checking errno
Contrary to the previous changesets in this series, this covers cases where
errno was checked for multiple values.
EACCES -> PermissionError
ENOENT -> FileNotFoundError
ENOTDIR -> NotADirectoryError
EISDIR -> IsADirectoryError
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Wed, 01 Jun 2022 00:47:25 +0200 |
parents | 97f2554cb647 |
children | 5cf73de964e1 |
line wrap: on
line diff
--- a/setup.py Tue May 31 23:45:33 2022 +0200 +++ b/setup.py Wed Jun 01 00:47:25 2022 +0200 @@ -95,7 +95,6 @@ ispypy = "PyPy" in sys.version import ctypes -import errno import stat, subprocess, time import re import shutil @@ -1422,15 +1421,12 @@ ) try: subprocess.check_call(cargocmd, env=env, cwd=self.rustsrcdir) - except OSError as exc: - if exc.errno == errno.ENOENT: - raise RustCompilationError("Cargo not found") - elif exc.errno == errno.EACCES: - raise RustCompilationError( - "Cargo found, but permission to execute it is denied" - ) - else: - raise + except FileNotFoundError: + raise RustCompilationError("Cargo not found") + except PermissionError: + raise RustCompilationError( + "Cargo found, but permission to execute it is denied" + ) except subprocess.CalledProcessError: raise RustCompilationError( "Cargo failed. Working directory: %r, "