Browse Source

support encoding bytes...

main
John-Mark Gurney 2 years ago
parent
commit
4091bc38cc
1 changed files with 2 additions and 1 deletions
  1. +2
    -1
      ui/medashare/btv/bencode.py

+ 2
- 1
ui/medashare/btv/bencode.py View File

@@ -295,6 +295,7 @@ def encode_dict(x,r):
encode_func = {}
encode_func[BencachedType] = encode_bencached
encode_func[int] = encode_int
encode_func[bytes] = encode_bytes
encode_func[str] = encode_string
encode_func[list] = encode_list
encode_func[tuple] = encode_list
@@ -319,7 +320,7 @@ def test_bencode():
assert bencode(12345678901234567890) == b'i12345678901234567890e'
assert bencode('') == b'0:'
assert bencode('abc') == b'3:abc'
assert bencode('1234567890') == b'10:1234567890'
assert bencode(b'1234567890') == b'10:1234567890'
assert bencode([]) == b'le'
assert bencode([1, 2, 3]) == b'li1ei2ei3ee'
assert bencode([['Alice', 'Bob'], [2, 3]]) == b'll5:Alice3:Bobeli2ei3eee'


Loading…
Cancel
Save