]> git.phdru.name Git - extfs.d.git/blobdiff - eff_bdecode.py
Fix(torrent): Process torrent file as binary
[extfs.d.git] / eff_bdecode.py
index fe1c4c245e54fa076c2f076c10b330de756f1b77..2f8fc5eb1d3caa9f3d384cbcfe9f455d7bb90950 100644 (file)
@@ -27,7 +27,7 @@ from functools import partial
 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)
@@ -38,7 +38,7 @@ def tokenize(text, match=re.compile("([idel])|(\\d+):|(-?\\d+)").match):
             yield text[i:i+int(s)]
             i = i + int(s)
         else:
-            yield s
+            yield s.decode('ascii')
 
 
 def decode_item(next_, token):