# HG changeset patch # User Santeri Piippo # Date 1402949533 -10800 # Node ID f604687dd35b11d3ae0ad4fc05a5fb9f3fb7ee22 # Parent 6672cecf3ed1dfab3bc48749f4cfc5a273d01a88 - don't try to send stuff we cannot convert to ascii.. I don't like it but it's better than a crash diff -r 6672cecf3ed1 -r f604687dd35b cobalt.py --- a/cobalt.py Mon Jun 16 00:14:56 2014 +0300 +++ b/cobalt.py Mon Jun 16 23:12:13 2014 +0300 @@ -220,8 +220,11 @@ print "Connected to [%s] %s:%d" % (self.name, self.host, self.port) self.register_to_irc() - def write (self, data): - self.send_buffer.append ("%s" % data) + def write (self, utfdata): + try: + self.send_buffer.append ("%s" % utfdata.decode("utf-8","ignore").encode("ascii","ignore")) + except UnicodeEncodeError: + pass def handle_close (self): print "Connection to [%s] %s:%d terminated." % (self.name, self.host, self.port) @@ -247,7 +250,7 @@ lines = self.recv (4096).splitlines() for utfline in lines: try: - line = utfline.decode("utf-8").encode("ascii","ignore") + line = utfline.decode("utf-8","ignore").encode("ascii","ignore") except UnicodeDecodeError: continue