From 6f3c21118f9d1c88d1a725381dea963d709f01f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Wed, 2 Aug 2017 18:56:25 +0200 Subject: [PATCH] Stay compatible to python 3.4 Fixes #8690 --- gajim/common/logger.py | 16 ++++++++-------- gajim/emoticons.py | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gajim/common/logger.py b/gajim/common/logger.py index 7a01a0294..64e97aa0d 100644 --- a/gajim/common/logger.py +++ b/gajim/common/logger.py @@ -676,7 +676,7 @@ class Logger: try: messages = self.con.execute( - sql, (*jids, restore, pending)).fetchall() + sql, tuple(jids) + (restore, pending)).fetchall() except sqlite.DatabaseError: self.dispatch('DB_ERROR', exceptions.DatabaseMalformed(LOG_DB_PATH)) @@ -722,8 +722,8 @@ class Logger: ORDER BY time, log_line_id '''.format(jids=', '.join('?' * len(jids))) - return self.con.execute(sql, (*jids, - date.timestamp(), + return self.con.execute(sql, tuple(jids) + + (date.timestamp(), (date + delta).timestamp())).fetchall() def search_log(self, account, jid, query, date=None): @@ -765,7 +765,7 @@ class Logger: '''.format(jids=', '.join('?' * len(jids)), date_search=between if date else '') - return self.con.execute(sql, (*jids, query)).fetchall() + return self.con.execute(sql, tuple(jids) + (query,)).fetchall() def get_days_with_logs(self, account, jid, year, month): """ @@ -803,8 +803,8 @@ class Logger: """.format(jids=', '.join('?' * len(jids)), kinds=', '.join(kinds)) - return self.con.execute(sql, (*jids, - date.timestamp(), + return self.con.execute(sql, tuple(jids) + + (date.timestamp(), (date + delta).timestamp())).fetchall() def get_last_date_that_has_logs(self, account, jid): @@ -831,7 +831,7 @@ class Logger: # fetchone() returns always at least one Row with all # attributes set to None because of the MAX() function - return self.con.execute(sql, (*jids,)).fetchone().time + return self.con.execute(sql, tuple(jids)).fetchone().time def get_room_last_message_time(self, account, jid): """ @@ -1210,7 +1210,7 @@ class Logger: '''.format(columns=', '.join(kwargs.keys()), values=', '.join('?' * len(kwargs))) - lastrowid = self.con.execute(sql, (jid, time_, kind, *kwargs.values())).lastrowid + lastrowid = self.con.execute(sql, (jid, time_, kind) + tuple(kwargs.values())).lastrowid if unread and kind == KindConstant.CHAT_MSG_RECV: sql = '''INSERT INTO unread_messages (message_id, jid_id) diff --git a/gajim/emoticons.py b/gajim/emoticons.py index 7f6abc35d..8fa0b4903 100644 --- a/gajim/emoticons.py +++ b/gajim/emoticons.py @@ -20,6 +20,7 @@ import sys import logging import importlib.util as imp from collections import OrderedDict +from importlib.machinery import SourceFileLoader from gi.repository import GdkPixbuf, Gtk, GLib @@ -65,10 +66,9 @@ def load(path): module_name = 'emoticons_theme.pyc' theme_path = os.path.join(path, module_name) - spec = imp.spec_from_file_location(module_name, theme_path) + loader = SourceFileLoader(module_name, theme_path) try: - theme = imp.module_from_spec(spec) - spec.loader.exec_module(theme) + theme = loader.load_module() except FileNotFoundError: log.exception('Emoticons theme not found') return