Mercurial > public > mercurial-scm > hg
diff mercurial/fileset.py @ 49310: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 | 642e31cb55f0 |
children | 18c8c18993f0 |
line wrap: on
line diff
--- a/mercurial/fileset.py Tue May 31 23:45:33 2022 +0200 +++ b/mercurial/fileset.py Wed Jun 01 00:47:25 2022 +0200 @@ -6,7 +6,6 @@ # GNU General Public License version 2 or any later version. -import errno import re from .i18n import _ @@ -575,16 +574,14 @@ return False try: return predfn(fctx) - except (IOError, OSError) as e: - # open()-ing a directory fails with EACCES on Windows - if e.errno in ( - errno.ENOENT, - errno.EACCES, - errno.ENOTDIR, - errno.EISDIR, - ): - return False - raise + # open()-ing a directory fails with PermissionError on Windows + except ( + FileNotFoundError, + PermissionError, + NotADirectoryError, + IsADirectoryError, + ): + return False else: