From 35bfd76852e9992ab060072e8ae6b2a3a552b085 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Tue, 5 Aug 2014 11:18:38 +0200 Subject: [PATCH] Factoids & Karma & MessageParser & MoobotFactoids & QuoteGrabs: Fix Pypy3 support (without breaking Python 2 support). --- plugins/Factoids/plugin.py | 7 +++++-- plugins/Karma/plugin.py | 6 +++++- plugins/MessageParser/plugin.py | 7 +++++-- plugins/MoobotFactoids/plugin.py | 7 +++++-- plugins/QuoteGrabs/plugin.py | 6 ++++-- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/plugins/Factoids/plugin.py b/plugins/Factoids/plugin.py index 78b008795..8305c7f27 100644 --- a/plugins/Factoids/plugin.py +++ b/plugins/Factoids/plugin.py @@ -29,6 +29,7 @@ ### import os +import sys import time import string import urllib @@ -217,10 +218,12 @@ class Factoids(callbacks.Plugin, plugins.ChannelDBHandler): def makeDb(self, filename): if os.path.exists(filename): db = sqlite3.connect(filename) - db.text_factory = str + if sys.version_info[0] < 3: + db.text_factory = str return db db = sqlite3.connect(filename) - db.text_factory = str + if sys.version_info[0] < 3: + db.text_factory = str cursor = db.cursor() cursor.execute("""CREATE TABLE keys ( id INTEGER PRIMARY KEY, diff --git a/plugins/Karma/plugin.py b/plugins/Karma/plugin.py index 0fb169fb1..6a50f5103 100644 --- a/plugins/Karma/plugin.py +++ b/plugins/Karma/plugin.py @@ -29,6 +29,7 @@ ### import os +import sys import csv import supybot.conf as conf @@ -58,10 +59,13 @@ class SqliteKarmaDB(object): return self.dbs[filename] if os.path.exists(filename): db = sqlite3.connect(filename, check_same_thread=False) - db.text_factory = str + if sys.version_info[0] < 3: + db.text_factory = str self.dbs[filename] = db return db db = sqlite3.connect(filename, check_same_thread=False) + if sys.version_info[0] < 3: + db.text_factory = str self.dbs[filename] = db cursor = db.cursor() cursor.execute("""CREATE TABLE karma ( diff --git a/plugins/MessageParser/plugin.py b/plugins/MessageParser/plugin.py index 821846894..9b1395af0 100644 --- a/plugins/MessageParser/plugin.py +++ b/plugins/MessageParser/plugin.py @@ -39,6 +39,7 @@ import supybot.ircdb as ircdb import re import os +import sys import time try: @@ -80,10 +81,12 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler): """Create the database and connect to it.""" if os.path.exists(filename): db = sqlite3.connect(filename) - db.text_factory = str + if sys.version_info[0] < 3: + db.text_factory = str return db db = sqlite3.connect(filename) - db.text_factory = str + if sys.version_info[0] < 3: + db.text_factory = str cursor = db.cursor() cursor.execute("""CREATE TABLE triggers ( id INTEGER PRIMARY KEY, diff --git a/plugins/MoobotFactoids/plugin.py b/plugins/MoobotFactoids/plugin.py index cff4186ad..6f3d972b5 100755 --- a/plugins/MoobotFactoids/plugin.py +++ b/plugins/MoobotFactoids/plugin.py @@ -28,6 +28,7 @@ ### import os +import sys import time import string @@ -106,11 +107,13 @@ class SqliteMoobotDB(object): if os.path.exists(filename): db = sqlite3.connect(filename, check_same_thread=False) - db.text_factory = str + if sys.version_info[0] < 3: + db.text_factory = str self.dbs[channel] = db return db db = sqlite3.connect(filename, check_same_thread=False) - db.text_factory = str + if sys.version_info[0] < 3: + db.text_factory = str self.dbs[channel] = db cursor = db.cursor() cursor.execute("""CREATE TABLE factoids ( diff --git a/plugins/QuoteGrabs/plugin.py b/plugins/QuoteGrabs/plugin.py index 0682d0177..c41de979e 100644 --- a/plugins/QuoteGrabs/plugin.py +++ b/plugins/QuoteGrabs/plugin.py @@ -82,12 +82,14 @@ class SqliteQuoteGrabsDB(object): return self.dbs[filename] if os.path.exists(filename): db = sqlite3.connect(filename) - db.text_factory = str + if sys.version_info[0] < 3: + db.text_factory = str db.create_function('nickeq', 2, p) self.dbs[filename] = db return db db = sqlite3.connect(filename) - db.text_factory = str + if sys.version_info[0] < 3: + db.text_factory = str db.create_function('nickeq', 2, p) self.dbs[filename] = db cursor = db.cursor()