mirror of
http://aero2k.de/t/repos/urlbot-native.git
synced 2017-09-06 15:25:38 +02:00
wrapped unicode() and ''.encode('utf8') inside exception
This commit is contained in:
@@ -88,8 +88,16 @@ def chat_write(message, prefix='/say '):
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
fd = open(fifo_path, 'wb')
|
fd = open(fifo_path, 'wb')
|
||||||
msg = unicode(prefix) + unicode(message) + '\n'
|
|
||||||
fd.write(msg.encode('utf8'))
|
# FIXME: somehow, unicode chars can end up inside a <str> message,
|
||||||
|
# which seems to make both unicode() and ''.encode('utf8') fail.
|
||||||
|
try:
|
||||||
|
msg = unicode(prefix) + unicode(message) + '\n'
|
||||||
|
msg.encode('utf8')
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
msg = prefix + message + '\n'
|
||||||
|
|
||||||
|
fd.write(msg)
|
||||||
fd.close()
|
fd.close()
|
||||||
except IOError:
|
except IOError:
|
||||||
logger('err', "couldn't print to fifo " + fifo_path)
|
logger('err', "couldn't print to fifo " + fifo_path)
|
||||||
|
|||||||
Reference in New Issue
Block a user