]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/compat.py
Prevent Python 3 from interfering with argv bytes
[bup.git] / lib / bup / compat.py
index f713f52253e27e7f792e2ed4f15c0c21eae948c9..47d0fa06cde5feebbd57e7f3b2f0acc726e00059 100644 (file)
@@ -12,6 +12,7 @@ py3 = py_maj >= 3
 
 if py3:
 
+    from os import fsencode
     from shlex import quote
     range = range
     str_type = str
@@ -27,6 +28,10 @@ if py3:
     def items(x):
         return x.items()
 
+    def argv_bytes(x):
+        """Return the original bytes passed to main() for an argv argument."""
+        return fsencode(x)
+
     def bytes_from_uint(i):
         return bytes((i,))
 
@@ -87,6 +92,10 @@ else:  # Python 2
     def items(x):
         return x.iteritems()
 
+    def argv_bytes(x):
+        """Return the original bytes passed to main() for an argv argument."""
+        return x
+
     def bytes_from_uint(i):
         return chr(i)