summaryrefslogtreecommitdiff
path: root/libmat2/torrent.py
diff options
context:
space:
mode:
authorjvoisin2018-07-08 22:27:37 +0200
committerjvoisin2018-07-08 22:27:37 +0200
commitf49aa5cab7862466573aea0db3b03a989cf2640b (patch)
treed2d26ab8d932b50ee702adc1d0435f0aabd42ab3 /libmat2/torrent.py
parent52a2c800b7f192c2da07025ae78350d5126e0200 (diff)
Achieve 100% coverage!
Diffstat (limited to 'libmat2/torrent.py')
-rw-r--r--libmat2/torrent.py6
1 files changed, 4 insertions, 2 deletions
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):
69 @staticmethod 69 @staticmethod
70 def __decode_string(s: bytes) -> Tuple[bytes, bytes]: 70 def __decode_string(s: bytes) -> Tuple[bytes, bytes]:
71 colon = s.index(b':') 71 colon = s.index(b':')
72 str_len = int(s[:colon]) 72 # FIXME Python3 is broken here, the call to `ord` shouldn't be needed,
73 if s[0] == '0' and colon != 1: 73 # but apparently it is. This is utterly idiotic.
74 if (s[0] == ord('0') or s[0] == '0') and colon != 1:
74 raise ValueError 75 raise ValueError
76 str_len = int(s[:colon])
75 s = s[1:] 77 s = s[1:]
76 return s[colon:colon+str_len], s[colon+str_len:] 78 return s[colon:colon+str_len], s[colon+str_len:]
77 79