Mercurial > hg-stable
diff mercurial/dirstate.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 | 2e726c934fcd |
children | 0043c7aa3250 |
line wrap: on
line diff
--- a/mercurial/dirstate.py Tue May 31 23:45:33 2022 +0200 +++ b/mercurial/dirstate.py Wed Jun 01 00:47:25 2022 +0200 @@ -8,7 +8,6 @@ import collections import contextlib -import errno import os import stat import uuid @@ -1035,13 +1034,11 @@ try: with tracing.log('dirstate.walk.traverse listdir %s', nd): entries = listdir(join(nd), stat=True, skip=skip) - except OSError as inst: - if inst.errno in (errno.EACCES, errno.ENOENT): - match.bad( - self.pathto(nd), encoding.strtolocal(inst.strerror) - ) - continue - raise + except (PermissionError, FileNotFoundError) as inst: + match.bad( + self.pathto(nd), encoding.strtolocal(inst.strerror) + ) + continue for f, kind, st in entries: # Some matchers may return files in the visitentries set, # instead of 'this', if the matcher explicitly mentions them