Fix bug in varint packing that caused 0s to throw an exception
This commit is contained in:
@@ -37,6 +37,8 @@ def bitlength(n):
|
||||
|
||||
def varint_pack(big):
|
||||
pos = True
|
||||
if big == 0:
|
||||
return '\x00'
|
||||
if big < 0:
|
||||
bytelength = bitlength(abs(big) - 1) / 8 + 1
|
||||
big = (1 << bytelength * 8) + big
|
||||
|
@@ -61,6 +61,7 @@ marshalled_value_pairs = (
|
||||
# vagaries of internal python ordering for unordered types
|
||||
('\x00\x03\x00\x06\xe3\x81\xbfbob\x00\x04\x00\x00\x00\xc7\x00\x00\x00\x04\xff\xff\xff\xff\x00\x01\\\x00\x04\x00\x00\x00\x00', 'MapType(UTF8Type, Int32Type)', {u'\u307fbob': 199, u'': -1, u'\\': 0}),
|
||||
('\x00\x02\x00\x08@\x14\x00\x00\x00\x00\x00\x00\x00\x08@\x01\x99\x99\x99\x99\x99\x9a', 'SetType(DoubleType)', set([2.2, 5.0])),
|
||||
('\x00', 'IntegerType', 0),
|
||||
)
|
||||
|
||||
class TestUnmarshal(unittest.TestCase):
|
||||
|
Reference in New Issue
Block a user