Mercurial > xib
diff bot.py @ 246:5e65f52be453
make sure Bot.error doesn't raise a transcoding exception and uses repr() when there is a problem
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Mon, 08 Mar 2010 18:39:53 +0100 |
parents | c9652650d5b5 |
children | 5d6ff929e6bc |
line wrap: on
line diff
--- a/bot.py +++ b/bot.py @@ -64,6 +64,10 @@ class Bot(threading.Thread): def error(self, importance, message, debug=False, no_debug_add='', send_to_admins=False): """Output an error message.""" + try: + message = message.encode('utf-8') + except: + message = repr(message) if not self.debug: message += no_debug_add if send_to_admins == True: @@ -71,9 +75,9 @@ class Bot(threading.Thread): if importance == -1: return if not debug: - self.error_fd.write(self.format_message(importance, message).encode('utf-8')+'\n') + self.error_fd.write(self.format_message(importance, message)+'\n') elif self.debug: - self.error_fd.write('='*importance+'> '+message.encode('utf-8')+'\n') + self.error_fd.write('='*importance+'> '+message+'\n') def _xmpp_loop(self):