brunobord/cmdbot — Issue #15: UnicodeDecodeError
Author: mozillalives
Created: 2012-01-14 05:11:19+00:00
State: open

This is probably just an error with my setup, but I got this error on a pretty default setup of ircd-hybrid.

INFO:root:Translation Not Found. Fallback to default
INFO:root:Connection to host...
Connection to host...
Traceback (most recent call last):
File "./eightball.py", line 33, in
bot.run()
File "/home/bot/env/lib/python2.7/site-packages/cmdbot/core.py", line 177, in run
readbuffer = readbuffer + self.s.recv(1024).decode('utf8')
File "/home/bot/env/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xc3 in position 1023: unexpected end of data

I was able to get the bot to work though by changing line 177 of cmdbot/core.py to the following

try:
readbuffer = readbuffer + self.s.recv(1024).decode('utf')
except UnicodeDecodeError:
continue