Pārlūkot izejas kodu

Fix Python 3.2 issue on FreeBSD

Jonas Borgström 12 gadi atpakaļ
vecāks
revīzija
df5e4a52a6
3 mainītis faili ar 10 papildinājumiem un 9 dzēšanām
  1. 3 6
      attic/archive.py
  2. 1 1
      attic/testsuite/__init__.py
  3. 6 2
      attic/xattr.py

+ 3 - 6
attic/archive.py

@@ -349,12 +349,9 @@ class Archive(object):
         }
         if self.numeric_owner:
             item[b'user'] = item[b'group'] = None
-        try:
-            xattrs = xattr.get_all(path, follow_symlinks=False)
-            if xattrs:
-                item[b'xattrs'] = xattrs
-        except PermissionError:
-            pass
+        xattrs = xattr.get_all(path, follow_symlinks=False)
+        if xattrs:
+            item[b'xattrs'] = xattrs
         return item
 
     def process_item(self, path, st):

+ 1 - 1
attic/testsuite/__init__.py

@@ -12,7 +12,7 @@ from attic.xattr import get_all
 if 'HAVE_FUTIMENS' in getattr(posix, '_have_functions', []):
     st_mtime_ns_round = 0
 elif 'HAVE_UTIMES' in sysconfig.get_config_vars():
-    st_mtime_ns_round = -4
+    st_mtime_ns_round = -6
 else:
     st_mtime_ns_round = -9
 

+ 6 - 2
attic/xattr.py

@@ -211,8 +211,12 @@ except ImportError:
             names = []
             mv = memoryview(namebuf.raw)
             while mv:
-                names.append(os.fsdecode(bytes(mv[1:1+mv[0]])))
-                mv = mv[1+mv[0]:]
+                length = mv[0]
+                # Python < 3.3 returns bytes instead of int
+                if isinstance(length, bytes):
+                    length = ord(length)
+                names.append(os.fsdecode(bytes(mv[1:1+length])))
+                mv = mv[1+length:]
             return names
 
         def getxattr(path, name, *, follow_symlinks=True):