py3: catch PermissionError instead of checking errno == EACCES
authorManuel Jacob <me@manueljacob.de>
Tue, 31 May 2022 23:38:51 +0200
changeset 49307 6f2a57ba2d13
parent 49306 2e726c934fcd
child 49308 d2adebe35635
py3: catch PermissionError instead of checking errno == EACCES
mercurial/posix.py
--- a/mercurial/posix.py	Tue May 31 22:50:01 2022 +0200
+++ b/mercurial/posix.py	Tue May 31 23:38:51 2022 +0200
@@ -302,18 +302,13 @@
                 try:
                     fullpath = os.path.join(cachedir, target)
                     open(fullpath, b'w').close()
-                except IOError as inst:
-                    # pytype: disable=unsupported-operands
-                    if inst[0] == errno.EACCES:
-                        # pytype: enable=unsupported-operands
-
-                        # If we can't write to cachedir, just pretend
-                        # that the fs is readonly and by association
-                        # that the fs won't support symlinks. This
-                        # seems like the least dangerous way to avoid
-                        # data loss.
-                        return False
-                    raise
+                except PermissionError:
+                    # If we can't write to cachedir, just pretend
+                    # that the fs is readonly and by association
+                    # that the fs won't support symlinks. This
+                    # seems like the least dangerous way to avoid
+                    # data loss.
+                    return False
             try:
                 os.symlink(target, name)
                 if cachedir is None: