]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/metadata.py
metadata: accept only fixed python-xattr in python3
[bup.git] / lib / bup / metadata.py
index 2f3ee06e0ad57839f5fc66c90f7feae21070981f..43694d4a1dc636a58b8a42d466d8687a1dd7b5b0 100644 (file)
@@ -15,22 +15,27 @@ import errno, os, sys, stat, time, pwd, grp, socket, struct
 from bup import vint, xstat
 from bup.drecurse import recursive_dirlist
 from bup.helpers import add_error, mkdirp, log, is_superuser, format_filesize
-from bup.helpers import pwd_from_uid, pwd_from_name, grp_from_gid, grp_from_name
+from bup.pwdgrp import pwd_from_uid, pwd_from_name, grp_from_gid, grp_from_name
 from bup.xstat import utime, lutime
 
 xattr = None
 if sys.platform.startswith('linux'):
+    # prefer python-pyxattr (it's a lot faster), but fall back to python-xattr
+    # as the two are incompatible and only one can be installed on a system
     try:
         import xattr
     except ImportError:
         log('Warning: Linux xattr support missing; install python-pyxattr.\n')
-    if xattr:
+    if xattr and getattr(xattr, 'get_all', None) is None:
         try:
-            xattr.get_all
-        except AttributeError:
-            log('Warning: python-xattr module is too old; '
-                'install python-pyxattr instead.\n')
+            from xattr import pyxattr_compat as xattr
+            if not isinstance(xattr.NS_USER, bytes):
+                xattr = None
+        except ImportError:
             xattr = None
+        if xattr is None:
+            log('Warning: python-xattr module is too old; '
+                'upgrade or install python-pyxattr instead.\n')
 
 posix1e = None
 if not (sys.platform.startswith('cygwin') \