|
|
@@ -70,9 +70,10 @@ def decode_list(x, f): |
|
|
|
|
|
|
|
def decode_dict(x, f): |
|
|
|
r, f = {}, f+1 |
|
|
|
lastkey = b'' |
|
|
|
lastkey = '' |
|
|
|
while x[f] != b'e'[0]: |
|
|
|
k, f = decode_string(x, f) |
|
|
|
k = k.decode('us-ascii') |
|
|
|
if lastkey >= k: |
|
|
|
raise ValueError |
|
|
|
lastkey = k |
|
|
@@ -199,8 +200,8 @@ def test_bdecode(): |
|
|
|
except ValueError: |
|
|
|
pass |
|
|
|
assert bdecode(b'de') == {} |
|
|
|
assert bdecode(b'd3:agei25e4:eyes4:bluee') == {b'age': 25, b'eyes': b'blue'} |
|
|
|
assert bdecode(b'd8:spam.mp3d6:author5:Alice6:lengthi100000eee') == {b'spam.mp3': {b'author': b'Alice', b'length': 100000}} |
|
|
|
assert bdecode(b'd3:agei25e4:eyes4:bluee') == {'age': 25, 'eyes': b'blue'} |
|
|
|
assert bdecode(b'd8:spam.mp3d6:author5:Alice6:lengthi100000eee') == {'spam.mp3': {'author': b'Alice', 'length': 100000}} |
|
|
|
try: |
|
|
|
bdecode(b'd3:fooe') |
|
|
|
assert 0 |
|
|
|