Mercurial > hg
changeset 49311:defc369d705e
py3: catch specific OSError subclasses instead of checking errno
On Python 3, the "not a directory" error is mapped to ENOTDIR instead of
EINVAL. Therefore, catching the NotADirectoryError subclass is sufficient.
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Wed, 01 Jun 2022 02:21:41 +0200 |
parents | 050dc8730858 |
children | fce591256085 |
files | mercurial/windows.py |
diffstat | 1 files changed, 1 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/windows.py Wed Jun 01 00:47:25 2022 +0200 +++ b/mercurial/windows.py Wed Jun 01 02:21:41 2022 +0200 @@ -576,11 +576,7 @@ for n, k, s in listdir(dir, True) if getkind(s.st_mode) in _wantedkinds } - except OSError as err: - # Python >= 2.5 returns ENOENT and adds winerror field - # EINVAL is raised if dir is not a directory. - if err.errno not in (errno.ENOENT, errno.EINVAL, errno.ENOTDIR): - raise + except (FileNotFoundError, NotADirectoryError): dmap = {} cache = dircache.setdefault(dir, dmap) yield cache.get(base, None)