Better errors on unexpected bencode data

Also fix indent.
This commit is contained in:
Tim Pope 2014-01-08 19:48:12 -05:00
parent 1f3f36505e
commit 0fdde20654

View File

@ -49,13 +49,17 @@ def bdecode(f, char=None):
if char == 'e':
return i
i = 10 * i + int(char)
else:
elif char.isdigit():
i = int(char)
while True:
char = f.read(1)
if char == ':':
return f.read(i)
i = 10 * i + int(char)
elif char == '':
raise EOFError("unexpected end of bencode data")
else:
raise TypeError("unexpected type "+char+"in bencode data")
class Connection: