diff options
Diffstat (limited to 'libmat2/torrent.py')
| -rw-r--r-- | libmat2/torrent.py | 6 |
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 | ||
