]> arthur.barton.de Git - bup.git/commitdiff
io: fix path_msg on python2
authorJohannes Berg <johannes@sipsolutions.net>
Thu, 27 Aug 2020 20:25:16 +0000 (22:25 +0200)
committerRob Browning <rlb@defaultvalue.org>
Sat, 29 Aug 2020 23:56:07 +0000 (18:56 -0500)
We get the binary representation here on both python 2 and 3,
but on 2 we really don't need to do any decoding since we must
print it as 'str'. Decoding also fails if the input is valid
UTF-8, which seems strange, but even if it worked we actually
don't want unicode objects here to print, we'd have to encode
them again to print.

Reported-by: Henninger Henningstone <henningstone@gmx.de>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/io.py

index 256f562451b4d12400f9ef44674997708f59d87c..512d36434ed57e800f3b1f647a8982a909ec6ac2 100644 (file)
@@ -7,12 +7,16 @@ from bup import compat
 if compat.py_maj > 2:
     def byte_stream(file):
         return file.buffer
+
+    def path_msg(x):
+        """Return a string representation of a path."""
+        # FIXME: configurability (might git-config quotePath be involved?)
+        return x.decode(errors='backslashreplace')
 else:
     def byte_stream(file):
         return file
 
-
-def path_msg(x):
-    """Return a string representation of a path."""
-    # FIXME: configurability (might git-config quotePath be involved?)
-    return x.decode(errors='backslashreplace')
+    def path_msg(x):
+        """Return a string representation of a path."""
+        # FIXME: configurability (might git-config quotePath be involved?)
+        return x