Преглед на файлове

remove misc. compat code not needed for py 3.4+

Thomas Waldmann преди 9 години
родител
ревизия
4444113414
променени са 5 файла, в които са добавени 4 реда и са изтрити 14 реда
  1. 1 1
      borg/compress.pyx
  2. 1 8
      borg/key.py
  3. 1 1
      borg/remote.py
  4. 1 1
      borg/repository.py
  5. 0 3
      borg/xattr.py

+ 1 - 1
borg/compress.pyx

@@ -110,7 +110,7 @@ cdef class LZ4(CompressorBase):
 
 class LZMA(CompressorBase):
     """
-    lzma compression / decompression (python 3.3+ stdlib)
+    lzma compression / decompression
     """
     ID = b'\x02\x00'
     name = 'lzma'

+ 1 - 8
borg/key.py

@@ -4,7 +4,7 @@ import getpass
 import os
 import sys
 import textwrap
-import hmac
+from hmac import HMAC
 from hashlib import sha256
 
 from .helpers import IntegrityError, get_keys_dir, Error
@@ -30,13 +30,6 @@ class RepoKeyNotFoundError(Error):
     """No key entry found in the config of repository {}."""
 
 
-class HMAC(hmac.HMAC):
-    """Workaround a bug in Python < 3.4 Where HMAC does not accept memoryviews
-    """
-    def update(self, msg):
-        self.inner.update(msg)
-
-
 def key_creator(repository, args):
     if args.encryption == 'keyfile':
         return KeyfileKey.create(repository, args)

+ 1 - 1
borg/remote.py

@@ -268,7 +268,7 @@ class RemoteRepository:
                     if not data:
                         raise ConnectionClosed()
                     data = data.decode('utf-8')
-                    for line in data.splitlines(True):  # keepends=True for py3.3+
+                    for line in data.splitlines(keepends=True):
                         if line.startswith('$LOG '):
                             _, level, msg = line.split(' ', 2)
                             level = getattr(logging, level, logging.CRITICAL)  # str -> int

+ 1 - 1
borg/repository.py

@@ -685,7 +685,7 @@ class LoggedIO:
             self.offset = 0
             self._write_fd.flush()
             os.fsync(self._write_fd.fileno())
-            if hasattr(os, 'posix_fadvise'):  # python >= 3.3, only on UNIX
+            if hasattr(os, 'posix_fadvise'):  # only on UNIX
                 # tell the OS that it does not need to cache what we just wrote,
                 # avoids spoiling the cache for the OS and other processes.
                 os.posix_fadvise(self._write_fd.fileno(), 0, 0, os.POSIX_FADV_DONTNEED)

+ 0 - 3
borg/xattr.py

@@ -231,9 +231,6 @@ elif sys.platform.startswith('freebsd'):  # pragma: freebsd only
         mv = memoryview(namebuf.raw)
         while mv:
             length = mv[0]
-            # Python < 3.3 returns bytes instead of int
-            if isinstance(length, bytes):
-                length = ord(length)
             names.append(os.fsdecode(bytes(mv[1:1+length])))
             mv = mv[1+length:]
         return names