Mercurial > public > mercurial-scm > hg-stable
diff mercurial/posix.py @ 49314: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 | 53e9422a9b45 |
children | 6f2a57ba2d13 |
line wrap: on
line diff
--- a/mercurial/posix.py Tue May 31 21:16:17 2022 +0200 +++ b/mercurial/posix.py Tue May 31 22:50:01 2022 +0200 @@ -175,9 +175,7 @@ using umask.""" try: st_mode = os.lstat(src).st_mode & 0o777 - except OSError as inst: - if inst.errno != errno.ENOENT: - raise + except FileNotFoundError: st_mode = mode if st_mode is None: st_mode = ~umask @@ -226,19 +224,16 @@ try: m = os.stat(checkisexec).st_mode - except OSError as e: - if e.errno != errno.ENOENT: - raise + except FileNotFoundError: # checkisexec does not exist - fall through ... + pass else: # checkisexec exists, check if it actually is exec if m & EXECFLAGS != 0: # ensure checkisexec exists, check it isn't exec try: m = os.stat(checknoexec).st_mode - except OSError as e: - if e.errno != errno.ENOENT: - raise + except FileNotFoundError: open(checknoexec, b'w').close() # might fail m = os.stat(checknoexec).st_mode if m & EXECFLAGS == 0: