]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/io.py
Update base_version to 0.34~ for 0.34 development
[bup.git] / lib / bup / io.py
index a384f1007e5d5f0452d646633a658b01b1dad9f0..e2fd410b3eb8b1eb444118acf06a8f8e88a8f62c 100644 (file)
@@ -1,27 +1,16 @@
 
-from __future__ import absolute_import, print_function
 import mmap as py_mmap
 
-from bup import compat
 from bup.compat import pending_raise
 
 
-if compat.py_maj > 2:
-    def byte_stream(file):
-        return file.buffer
+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
+def path_msg(x):
+    """Return a string representation of a path."""
+    # FIXME: configurability (might git-config quotePath be involved?)
+    return x.decode(errors='backslashreplace')
 
 
 assert not hasattr(py_mmap.mmap, '__del__')
@@ -33,14 +22,17 @@ class mmap(py_mmap.mmap):
     that aren't explicitly closed.
 
     '''
+    def __new__(cls, *args, **kwargs):
+        result = super().__new__(cls, *args, **kwargs)
+        result._bup_closed = True  # supports __del__
+        return result
 
     def __init__(self, *args, **kwargs):
-        self._bup_closed = True
         # Silence deprecation warnings.  mmap's current parent is
         # object, which accepts no params and as of at least 2.7
         # warns about them.
         if py_mmap.mmap.__init__ is not object.__init__:
-            super(mmap, self).__init__(self, *args, **kwargs)
+            super().__init__(self, *args, **kwargs)
         self._bup_closed = False
 
     def close(self):