From c0d4330383c10ca21143ea596e200d87f17540fe Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Sun, 15 Nov 2015 09:13:12 -0800 Subject: [PATCH] failed hopes --- core/irc.py | 12 ++++++++---- core/main.py | 3 ++- plugins/util/urlnorm.py | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/core/irc.py b/core/irc.py index ff44327..fbf4aac 100644 --- a/core/irc.py +++ b/core/irc.py @@ -66,7 +66,9 @@ class crlf_tcp(object): while True: try: data = self.recv_from_socket(4096) - self.ibuffer += data + print(type(self.ibuffer)) + print(type(data)) + self.ibuffer += (data.decode('utf-8')) if data: last_timestamp = time.time() else: @@ -88,9 +90,11 @@ class crlf_tcp(object): while True: line = self.oqueue.get().splitlines()[0][:500] print(">>> %r" % line) - self.obuffer += line.encode('utf-8', 'replace') + '\r\n' - while self.obuffer: - sent = self.socket.send(self.obuffer) + + self.obuffer += (line + '\r\n') + + while len(self.obuffer) > 0: + sent = self.socket.send(self.obuffer.encode('utf-8', 'replace')) self.obuffer = self.obuffer[sent:] diff --git a/core/main.py b/core/main.py index 460f3a7..d6c42ce 100644 --- a/core/main.py +++ b/core/main.py @@ -1,6 +1,7 @@ import fuckit import _thread import traceback +import queue _thread.stack_size(1024 * 512) # reduce vm size @@ -99,7 +100,7 @@ class Handler(object): def __init__(self, func): self.func = func - self.input_queue = Queue.Queue() + self.input_queue = queue.Queue() _thread.start_new_thread(self.start, ()) def start(self): diff --git a/plugins/util/urlnorm.py b/plugins/util/urlnorm.py index 05187c5..40af7bd 100644 --- a/plugins/util/urlnorm.py +++ b/plugins/util/urlnorm.py @@ -73,7 +73,7 @@ def normalize(url): # Always use uppercase A-through-F characters when percent-encoding. # All portions of the URI must be utf-8 encoded NFC from Unicode strings def clean(string): - string = str(unquote(string), 'utf-8', 'replace') + string = b""+(unquote(string)).decode('utf-8', 'replace') return unicodedata.normalize('NFC', string).encode('utf-8') path = quote(clean(path), "~:/?#[]@!$&'()*+,;=") fragment = quote(clean(fragment), "~")