remove misc. compat code not needed for py 3.4+

This commit is contained in:
Thomas Waldmann 2015-12-14 23:07:06 +01:00
parent 6a5629226f
commit 4444113414
5 changed files with 4 additions and 14 deletions

View file

@ -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'

View file

@ -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)

View file

@ -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

View file

@ -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)

View file

@ -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