From f49aa5cab7862466573aea0db3b03a989cf2640b Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sun, 8 Jul 2018 22:27:37 +0200 Subject: Achieve 100% coverage! --- libmat2/torrent.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libmat2/torrent.py') diff --git a/libmat2/torrent.py b/libmat2/torrent.py index c1ea2ca..0f122b0 100644 --- a/libmat2/torrent.py +++ b/libmat2/torrent.py @@ -69,9 +69,11 @@ class _BencodeHandler(object): @staticmethod def __decode_string(s: bytes) -> Tuple[bytes, bytes]: colon = s.index(b':') - str_len = int(s[:colon]) - if s[0] == '0' and colon != 1: + # FIXME Python3 is broken here, the call to `ord` shouldn't be needed, + # but apparently it is. This is utterly idiotic. + if (s[0] == ord('0') or s[0] == '0') and colon != 1: raise ValueError + str_len = int(s[:colon]) s = s[1:] return s[colon:colon+str_len], s[colon+str_len:] -- cgit v1.3