Better errors on unexpected bencode data
Also fix indent.
This commit is contained in:
parent
1f3f36505e
commit
0fdde20654
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user