]> arthur.barton.de Git - bup.git/commitdiff
metadata: accept only fixed python-xattr in python3
authorJohannes Berg <johannes@sipsolutions.net>
Sun, 12 Jan 2020 23:08:25 +0000 (00:08 +0100)
committerRob Browning <rlb@defaultvalue.org>
Fri, 17 Jan 2020 17:03:32 +0000 (11:03 -0600)
This is currently broken on python3, it returns junk when
we pass bytes because it uses string and %s internally.
I made a fix for it, so we can detect here if it's fixed
(in which case the NS_USER constant is bytes, not string),
load the module only if it is indeed fixed.

We can do this test always since in python2 bytes == str
and thus isinstance('user', bytes) == True.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/metadata.py

index fe1d5f378e5750da4d52c707241c0d7787f4cc19..43694d4a1dc636a58b8a42d466d8687a1dd7b5b0 100644 (file)
@@ -29,10 +29,13 @@ if sys.platform.startswith('linux'):
     if xattr and getattr(xattr, 'get_all', None) is None:
         try:
             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')
-            xattr = None
 
 posix1e = None
 if not (sys.platform.startswith('cygwin') \