effigies / BitTornado

UNMAINTAINED - John Hoffman's fork of the original bittorrent
Other
150 stars 44 forks source link

codec can't decode byte 0xa0 in position 13 #51

Open Yuuki2012 opened 8 years ago

Yuuki2012 commented 8 years ago

I don't have the Traceback from the 'str' TypeError, it disappeared in my screen window

TypeError: 'str' does not support the buffer interface
Traceback (most recent call last):
  File "/home/BitTornado/BitTornado/Network/RawServer.py", line 120, in listen_forever
    self.sockethandler.handle_events(events)
  File "/home/BitTornado/BitTornado/Network/SocketHandler.py", line 296, in handle_events
    s.handler.data_came_in(s, data)
  File "/home/BitTornado/BitTornado/Tracker/HTTPHandler.py", line 148, in data_came_in
    if not c.data_came_in(data) and not c.closed:
  File "/home/BitTornado/BitTornado/Tracker/HTTPHandler.py", line 35, in data_came_in
    self.next_func = self.next_func(val.decode())
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 13: invalid start byte
Traceback (most recent call last):
  File "/home/BitTornado/BitTornado/Network/RawServer.py", line 120, in listen_forever
    self.sockethandler.handle_events(events)
  File "/home/BitTornado/BitTornado/Network/SocketHandler.py", line 296, in handle_events
    s.handler.data_came_in(s, data)
  File "/home/BitTornado/BitTornado/Tracker/HTTPHandler.py", line 148, in data_came_in
    if not c.data_came_in(data) and not c.closed:
  File "/home/BitTornado/BitTornado/Tracker/HTTPHandler.py", line 35, in data_came_in
    self.next_func = self.next_func(val.decode())

Hi again ^^ I have a new error for you, I'm assuming it's caused by a '!' in the filename, I'm currently trying to test this. (basically moving the file out of the parse directory and check if the error still appears)

EDIT: I removed the ' ! ' from the filename and the error seems to have disappeared, I'll edit or reply again when I see the same error again.

EDIT2: Nope that was not the issue, I don't know what else it could be.

effigies commented 8 years ago

Hmm. I'll have a look. Thanks for the report.

effigies commented 8 years ago

What branch/commit are you using?

Yuuki2012 commented 8 years ago

The latest one I should be using (with the latest error fix I've reported)

$ git pull origin issue_46 ^ last command I've ran

$ git branch

Yuuki2012 commented 8 years ago

Changing the

self.next_func = self.next_func(val.decode())

to

self.next_func = self.next_func(val.decode('cp1252'))

on Tracker/HTTPHandler.py seems to have worked, I'm not sure if I should be using cp1252 but it fixed the crashing at least. (for now)

effigies commented 8 years ago

I suspect that works only because 0xA0 is a valid code point in cp1252, not that information is actually being transmitted in cp1252.

Is it a specific .torrent file that's causing this issue? If you could share that, I may be able to reproduce and track down the bug.

Yuuki2012 commented 8 years ago

I'm not sure which torrent it is (or if it's even a torrent causing it), but SHOULD be one of these: http://www.nyaa.se/?page=download&tid=851191 http://www.nyaa.se/?page=download&tid=851185 http://www.nyaa.se/?page=download&tid=851095 http://www.nyaa.se/?page=download&tid=851203 those were uploaded before the crashes happened