summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2020-01-12 23:55:21 +0100
committerJohannes Berg <johannes.berg@intel.com>2020-01-13 09:19:15 +0100
commit6ea2434a407410e7d61a0e878b11cfa139ae53c1 (patch)
treeef9e0ff2c7a169ace8148328c18a736fcb0446a1
parent0fb162fcab88020547033a31ab05f8dd64f53eb4 (diff)
downloadxattr-6ea2434a407410e7d61a0e878b11cfa139ae53c1.tar.gz
pyxattr_compat: make compatible with python3 xattr
On python3, xattr expects everything to be bytes, follow suit.
-rw-r--r--xattr/pyxattr_compat.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/xattr/pyxattr_compat.py b/xattr/pyxattr_compat.py
index 3d594de..c9242d3 100644
--- a/xattr/pyxattr_compat.py
+++ b/xattr/pyxattr_compat.py
@@ -20,10 +20,10 @@ __all__ = [
"removexattr", "remove", "listxattr", "list"
]
-NS_SECURITY = "security"
-NS_USER = "user"
-NS_SYSTEM = "system"
-NS_TRUSTED = "trusted"
+NS_SECURITY = b"security"
+NS_USER = b"user"
+NS_SYSTEM = b"system"
+NS_TRUSTED = b"trusted"
_NO_NS = object()
@@ -47,7 +47,7 @@ def _add_ns(item, ns):
raise TypeError("namespace must not be None")
if ns == _NO_NS:
return item
- return "%s.%s" % (ns, item)
+ return b'.'.join((ns, item))
def getxattr(item, attribute, nofollow=False):
options = nofollow and XATTR_NOFOLLOW or 0
@@ -59,7 +59,7 @@ def get(item, name, nofollow=False, namespace=_NO_NS):
def get_all(item, nofollow=False, namespace=_NO_NS):
if namespace is not None and namespace != _NO_NS:
- namespace = '%s.' % namespace
+ namespace += b'.'
l = listxattr(item, nofollow=nofollow)
result = []
for name in l:
@@ -101,7 +101,7 @@ def listxattr(item, nofollow=False):
def list(item, nofollow=False, namespace=_NO_NS):
if not namespace or namespace == _NO_NS:
return listxattr(item, nofollow=nofollow)
- namespace = "%s." % namespace
+ namespace += b'.'
l = listxattr(item, nofollow=nofollow)
result = []
for name in l: