Browse Source

Avoid using PermissionError, which is Python3 only.

Jelmer Vernooij 5 years ago
parent
commit
29fc0ac210
2 changed files with 11 additions and 2 deletions
  1. 7 0
      NEWS
  2. 4 2
      dulwich/repo.py

+ 7 - 0
NEWS

@@ -1,3 +1,10 @@
+0.19.13	UNRELEASED
+
+ BUG FIXES
+
+ * Avoid ``PermissionError``, since it is Python3-specific.
+  (Jelmer Vernooij)
+
 0.19.12	2019-08-13
 
  BUG FIXES

+ 4 - 2
dulwich/repo.py

@@ -996,8 +996,10 @@ class Repo(BaseRepo):
         st1 = os.lstat(fname)
         try:
             os.chmod(fname, st1.st_mode ^ stat.S_IXUSR)
-        except PermissionError:
-            return False
+        except EnvironmentError as e:
+            if e.errno == errno.EPERM:
+                return False
+            raise
         st2 = os.lstat(fname)
 
         os.unlink(fname)