keys can be binary
This commit is contained in:
parent
1fb697b48b
commit
5168459936
1 changed files with 5 additions and 1 deletions
|
@ -24,6 +24,10 @@ def _decode_str(data):
|
||||||
raise Exception('invalid string size: %d' % l)
|
raise Exception('invalid string size: %d' % l)
|
||||||
start += 1
|
start += 1
|
||||||
ret = bytes(data[start:start+l])
|
ret = bytes(data[start:start+l])
|
||||||
|
try:
|
||||||
|
ret = ret.decode('utf-8')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
data = data[start+l:]
|
data = data[start+l:]
|
||||||
return ret, data
|
return ret, data
|
||||||
|
|
||||||
|
@ -49,7 +53,7 @@ def _decode_dict(data):
|
||||||
while data[0] != ord(b'e'):
|
while data[0] != ord(b'e'):
|
||||||
k, data = _decode_str(data)
|
k, data = _decode_str(data)
|
||||||
v, data = _decode(data)
|
v, data = _decode(data)
|
||||||
d[k.decode()] = v
|
d[k] = v
|
||||||
return d, data[1:]
|
return d, data[1:]
|
||||||
|
|
||||||
def _decode(data):
|
def _decode(data):
|
||||||
|
|
Loading…
Reference in a new issue