From 629ede010affdb81f4b9ed460a2670fa2b7d33cb Mon Sep 17 00:00:00 2001 From: Daniel Folkinshteyn Date: Wed, 17 Mar 2010 13:19:07 -0400 Subject: [PATCH] forget about unicode, and just use text_factory str for sqlite to retrieve raw bytes out of text fields without conversions. --- plugins/MessageParser/plugin.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/MessageParser/plugin.py b/plugins/MessageParser/plugin.py index 73269fde9..8c2c06472 100644 --- a/plugins/MessageParser/plugin.py +++ b/plugins/MessageParser/plugin.py @@ -72,8 +72,11 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler): def makeDb(self, filename): """Create the database and connect to it.""" if os.path.exists(filename): - return sqlite3.connect(filename) + db = sqlite3.connect(filename) + db.text_factory = str + return db db = sqlite3.connect(filename) + db.text_factory = str cursor = db.cursor() cursor.execute("""CREATE TABLE triggers ( id INTEGER PRIMARY KEY, @@ -115,7 +118,7 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler): def _runCommandFunction(self, irc, msg, command): """Run a command from message, as if command was sent over IRC.""" # need to encode it from unicode, since sqlite stores text as unicode. - tokens = callbacks.tokenize(unicode.encode(command, 'utf8')) + tokens = callbacks.tokenize(command) try: self.Proxy(irc.irc, msg, tokens) except Exception, e: