From: Christian Heller Date: Mon, 18 Jan 2016 21:40:36 +0000 (+0100) Subject: In recv_line(), handle UnicodeDecodeErrors by assuming latin1. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/tasks?a=commitdiff_plain;h=0d17c0577b6e816dc1c6e02667fc03f74ef5f4a8;p=plomlombot-irc.git In recv_line(), handle UnicodeDecodeErrors by assuming latin1. --- diff --git a/plomlombot.py b/plomlombot.py index 81be31f..0b605e9 100755 --- a/plomlombot.py +++ b/plomlombot.py @@ -67,7 +67,11 @@ class IO: self._pingtest(send_ping) return None self.last_pong = time.time() - received_runes = self.socket.recv(1024).decode("UTF-8") + received_bytes = self.socket.recv(1024) + try: + received_runes = received_bytes.decode("UTF-8") + except UnicodeDecodeError: + received_runes = received_bytes.decode("latin1") if len(received_runes) == 0: print("SOCKET CONNECTION BROKEN") raise ExceptionForRestart