Mercurial > hg
diff mercurial/util.py @ 49306:2e726c934fcd
py3: catch FileNotFoundError instead of checking errno == ENOENT
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Tue, 31 May 2022 22:50:01 +0200 |
parents | c6a3243567b6 |
children | d2adebe35635 |
line wrap: on
line diff
--- a/mercurial/util.py Tue May 31 21:16:17 2022 +0200 +++ b/mercurial/util.py Tue May 31 22:50:01 2022 +0200 @@ -2426,9 +2426,7 @@ def frompath(cls, path): try: stat = os.stat(path) - except OSError as err: - if err.errno != errno.ENOENT: - raise + except FileNotFoundError: stat = None return cls(stat) @@ -2612,12 +2610,11 @@ def tryunlink(f): # type: (bytes) -> None - """Attempt to remove a file, ignoring ENOENT errors.""" + """Attempt to remove a file, ignoring FileNotFoundError.""" try: unlink(f) - except OSError as e: - if e.errno != errno.ENOENT: - raise + except FileNotFoundError: + pass def makedirs(name, mode=None, notindexed=False):