keys can be binary

This commit is contained in:
j 2016-08-29 22:58:54 +02:00
parent 1fb697b48b
commit 5168459936

View file

@ -24,6 +24,10 @@ def _decode_str(data):
raise Exception('invalid string size: %d' % l)
start += 1
ret = bytes(data[start:start+l])
try:
ret = ret.decode('utf-8')
except:
pass
data = data[start+l:]
return ret, data
@ -49,7 +53,7 @@ def _decode_dict(data):
while data[0] != ord(b'e'):
k, data = _decode_str(data)
v, data = _decode(data)
d[k.decode()] = v
d[k] = v
return d, data[1:]
def _decode(data):