diff options
author | Tim Burke <tim.burke@gmail.com> | 2021-05-27 21:19:23 -0700 |
---|---|---|
committer | Tim Burke <tim.burke@gmail.com> | 2021-05-27 21:19:23 -0700 |
commit | 8066019b71da7c9240404e8d80b03175a469dbf0 (patch) | |
tree | 6c25d6f89624344c9645d78e10862d2b1ca65653 /xattr | |
parent | 3e146d58daa9b17d4ff9d32a185d5d9bbaf45b16 (diff) | |
download | xattr-8066019b71da7c9240404e8d80b03175a469dbf0.tar.gz |
tool: Fix dumping on py2
Previously, translate() would complain
TypeError: character mapping must return integer, None or unicode
Diffstat (limited to 'xattr')
-rwxr-xr-x | xattr/tool.py | 9 |
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): |