import re
-def tokenize(text, match=re.compile("([idel])|(\\d+):|(-?\\d+)").match):
+def tokenize(text, match=re.compile(b"([idel])|(\\d+):|(-?\\d+)").match):
i = 0
while i < len(text):
m = match(text, i)
yield text[i:i+int(s)]
i = i + int(s)
else:
- yield s
+ yield s.decode('ascii')
def decode_item(next_, token):
def decode_torrent():
try:
- torrent_file = open(sys.argv[2], 'r')
+ torrent_file = open(sys.argv[2], 'rb')
data = torrent_file.read()
torrent_file.close()
return decode(data)