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)
|
||||
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):
|
||||
|
|
Loading…
Reference in a new issue