home · contact · privacy
In recv_line(), handle UnicodeDecodeErrors by assuming latin1.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 18 Jan 2016 21:40:36 +0000 (22:40 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 18 Jan 2016 21:40:36 +0000 (22:40 +0100)
plomlombot.py

index 81be31fdb5f438349469e7d63afac9b4b20b1a7e..0b605e9946b04f79a8f3e843da56eee2b59b0169 100755 (executable)
@@ -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