summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Burke <tim.burke@gmail.com>2021-05-27 21:19:23 -0700
committerTim Burke <tim.burke@gmail.com>2021-05-27 21:19:23 -0700
commit8066019b71da7c9240404e8d80b03175a469dbf0 (patch)
tree6c25d6f89624344c9645d78e10862d2b1ca65653
parent3e146d58daa9b17d4ff9d32a185d5d9bbaf45b16 (diff)
downloadxattr-8066019b71da7c9240404e8d80b03175a469dbf0.tar.gz
tool: Fix dumping on py2
Previously, translate() would complain TypeError: character mapping must return integer, None or unicode
-rwxr-xr-xxattr/tool.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/xattr/tool.py b/xattr/tool.py
index a7cfb47..89b9221 100755
--- a/xattr/tool.py
+++ b/xattr/tool.py
@@ -67,7 +67,14 @@ def usage(e=None):
sys.exit(0)
-_FILTER = ''.join([(len(repr(chr(x))) == 3) and chr(x) or '.' for x in range(256)])
+if sys.version_info < (3,):
+ ascii = repr
+ uchr = unichr
+else:
+ uchr = chr
+
+
+_FILTER = u''.join([(len(ascii(chr(x))) == 3) and uchr(x) or u'.' for x in range(256)])
def _dump(src, length=16):