diff -r d54b213c4380 -r 050dc8730858 mercurial/posix.py --- a/mercurial/posix.py Tue May 31 23:45:33 2022 +0200 +++ b/mercurial/posix.py Wed Jun 01 00:47:25 2022 +0200 @@ -581,9 +581,7 @@ st = lstat(nf) if getkind(st.st_mode) not in _wantedkinds: st = None - except OSError as err: - if err.errno not in (errno.ENOENT, errno.ENOTDIR): - raise + except (FileNotFoundError, NotADirectoryError): st = None yield st