From 45299a0498d9d0fdcfe86c3326a71acf16177442 Mon Sep 17 00:00:00 2001 From: "mr.Shu" Date: Mon, 28 Dec 2015 00:50:39 +0100 Subject: [PATCH] irc: Fix random `UnicodeDecodeError`s * In #569 it was reported that `UnicodeDecodeError`s are thrown randomly when the IRC backend is used. This commit tries to resolve this situation by using a replacement character for unrecognized byte sequences as described at https://pypi.python.org/pypi/irc Signed-off-by: mr.Shu --- errbot/backends/irc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/errbot/backends/irc.py b/errbot/backends/irc.py index 67d91f89c..574a32e7c 100644 --- a/errbot/backends/irc.py +++ b/errbot/backends/irc.py @@ -304,6 +304,11 @@ def __init__(self, super().__init__([(server, port, password)], nickname, username, reconnection_interval=reconnect_on_disconnect) def connect(self, *args, **kwargs): + # Decode all input to UTF-8, but use a replacement character for + # unrecognized byte sequences + # (as described at https://pypi.python.org/pypi/irc) + self.connection.buffer_class.errors = 'replace' + connection_factory_kwargs = {} if self.use_ssl: import ssl