diff mercurial/lock.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 2e726c934fcd
children 5586076b8030
line wrap: on
line diff
--- a/mercurial/lock.py	Tue May 31 23:45:33 2022 +0200
+++ b/mercurial/lock.py	Wed Jun 01 00:47:25 2022 +0200
@@ -38,9 +38,8 @@
     if pycompat.sysplatform.startswith(b'linux'):
         try:
             result += b'/%x' % os.stat(b'/proc/self/ns/pid').st_ino
-        except OSError as ex:
-            if ex.errno not in (errno.ENOENT, errno.EACCES, errno.ENOTDIR):
-                raise
+        except (FileNotFoundError, PermissionError, NotADirectoryError):
+            pass
     return result