From df5e4a52a61aa49cff502490a4cc26feff8459b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Mon, 29 Jul 2013 21:09:31 +0200 Subject: [PATCH] Fix Python 3.2 issue on FreeBSD --- attic/archive.py | 9 +++------ attic/testsuite/__init__.py | 2 +- attic/xattr.py | 8 ++++++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/attic/archive.py b/attic/archive.py index 774bfc6e3..d001d4e66 100644 --- a/attic/archive.py +++ b/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): diff --git a/attic/testsuite/__init__.py b/attic/testsuite/__init__.py index 658a87cf7..76a6b08dd 100644 --- a/attic/testsuite/__init__.py +++ b/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 diff --git a/attic/xattr.py b/attic/xattr.py index cc0d5a279..df49b46a8 100644 --- a/attic/xattr.py +++ b/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):