From 4091bc38ccd9fbe136c46a46e8fc62eec4edab86 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Sat, 27 Aug 2022 17:24:58 -0700 Subject: [PATCH] support encoding bytes... --- ui/medashare/btv/bencode.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/medashare/btv/bencode.py b/ui/medashare/btv/bencode.py index 1ba522f..70d24ff 100644 --- a/ui/medashare/btv/bencode.py +++ b/ui/medashare/btv/bencode.py @@ -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'