# This code is covered under the terms of the GNU Library General
# Public License as described in the bup LICENSE file.
-from cStringIO import StringIO
+from io import BytesIO
# Variable length integers are encoded as vints -- see jakarta lucene.
if b & 0x80:
offset += 6
c = port.read(1)
+ elif negative:
+ return -result
else:
- return -result if negative else result
+ return result
while c:
b = ord(c)
if b & 0x80:
else:
result |= (b << offset)
break
- return -result if negative else result
+ if negative:
+ return -result
+ else:
+ return result
def write_bvec(port, x):
def pack(types, *args):
if len(types) != len(args):
raise Exception('number of arguments does not match format string')
- port = StringIO()
+ port = BytesIO()
for (type, value) in zip(types, args):
if type == 'V':
write_vuint(port, value)
def unpack(types, data):
result = []
- port = StringIO(data)
+ port = BytesIO(data)
for type in types:
if type == 'V':
result.append(read_vuint(port))