Skip to content
Commits on Source (2)
......@@ -96,8 +96,8 @@ class ProtocolError(Exception):
class Protocol:
def __init__(self, input, output):
self._input = input
def __init__(self, myinput, output):
self._input = myinput
self._output = output
def _readline(self):
......@@ -129,8 +129,8 @@ class Protocol:
class Master(Protocol):
def __init__(self, input, output):
Protocol.__init__(self, input, output)
def __init__(self, myinput, output):
Protocol.__init__(self, myinput, output)
self._commands = {
"section": self._switch_section,
"recycle": self._recycle,
......
......@@ -33,6 +33,17 @@ class DecompressedStream():
self._line_buffer = []
self._i = 0
self._end = 0
self._undecbuf = b''
def _split_decode(self, myb):
lmyb = len(myb)
for end in range(lmyb, max(lmyb-6, -1), -1):
try:
return myb[:end].decode(), myb[end:]
except UnicodeDecodeError:
pass
# not returned yet? We have a problem
raise UnicodeDecodeError
def _refill(self):
if self._input is None:
......@@ -46,7 +57,8 @@ class DecompressedStream():
if self._decompressor:
chunk = self._decompressor.decompress(chunk)
if isinstance(chunk, bytes):
chunk = chunk.decode()
chunk = self._undecbuf + chunk
chunk, self._undecbuf = self._split_decode(chunk)
self._buffer = self._buffer + chunk
if chunk:
return True
......
......@@ -51,8 +51,8 @@ class _Cursor:
"""Store an input string and a movable location in it"""
def __init__(self, input):
self._input = input
def __init__(self, myinput):
self._input = myinput
self._len = len(self._input)
self._pos = 0
......
......@@ -47,10 +47,10 @@ import six
apt_pkg.init_system()
def rfc822_like_header_parse(input):
def rfc822_like_header_parse(myinput):
headers = []
while True:
line = input.readline()
line = myinput.readline()
if not line or line in ["\r\n", "\n"]:
break
if headers and line and line[0].isspace():
......@@ -184,10 +184,10 @@ class PackagesFile(UserDict):
stream.close()
self._urllist.append(url)
def _read_file(self, input, restrict_packages=None):
def _read_file(self, myinput, restrict_packages=None):
"""Parse a Packages file and add its packages to us-the-dict"""
while True:
headers = rfc822_like_header_parse(input)
headers = rfc822_like_header_parse(myinput)
if not headers:
break
p = Package(headers)
......