From 9ce9ee5fec21bb49e799a76583555d176bfd69d8 Mon Sep 17 00:00:00 2001 From: undeath Date: Tue, 11 Dec 2018 23:27:13 +0100 Subject: [PATCH] fix encode crash on irc notice --- jmdaemon/jmdaemon/irc.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/jmdaemon/jmdaemon/irc.py b/jmdaemon/jmdaemon/irc.py index 0e6553c..16db483 100644 --- a/jmdaemon/jmdaemon/irc.py +++ b/jmdaemon/jmdaemon/irc.py @@ -19,11 +19,20 @@ log = get_log() def wlog(*x): """Simplifier to add lists to the debug log """ + def conv(s): + # note: this only works because of the future package + if isinstance(s, str): + return s + elif isinstance(s, bytes): + return s.decode('utf-8', errors='ignore') + else: + return str(s) + if x[0] == "WARNING": - msg = " ".join([str(a) for a in x[1:]]) + msg = " ".join([conv(a) for a in x[1:]]) log.warn(msg) else: - msg = " ".join([str(a) for a in x]) + msg = " ".join([conv(a) for a in x]) log.debug(msg) def get_irc_text(line): @@ -402,4 +411,4 @@ class txIRC_Client(irc.IRCClient, object): #wlog('(unhandled) left: ', channel) def noticed(self, user, channel, message): - wlog('(unhandled) noticed: ', user, channel, message) \ No newline at end of file + wlog('(unhandled) noticed: ', user, channel, message)