diff --git a/deluge/config.py b/deluge/config.py index 9e3ee9187..808e5b587 100644 --- a/deluge/config.py +++ b/deluge/config.py @@ -41,7 +41,6 @@ version as this will be done internally. """ from __future__ import unicode_literals -import cPickle as pickle import json import logging import os @@ -49,6 +48,8 @@ import shutil from codecs import getwriter from io import open +import six.moves.cPickle as pickle + from deluge.common import JSON_FORMAT, get_default_config_dir log = logging.getLogger(__name__) diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 86ad76466..38cdcbf49 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -10,13 +10,13 @@ """TorrentManager handles Torrent objects""" from __future__ import unicode_literals -import cPickle as pickle import datetime import logging import operator import os import time +import six.moves.cPickle as pickle from twisted.internet import defer, error, reactor, threads from twisted.internet.defer import Deferred, DeferredList from twisted.internet.task import LoopingCall diff --git a/deluge/event.py b/deluge/event.py index b80e12936..b6a48508b 100644 --- a/deluge/event.py +++ b/deluge/event.py @@ -16,6 +16,8 @@ and subsequently emitted to the clients. """ from __future__ import unicode_literals +import six + known_events = {} @@ -29,7 +31,7 @@ class DelugeEventMetaClass(type): known_events[name] = cls -class DelugeEvent(object): +class DelugeEvent(six.with_metaclass(DelugeEventMetaClass, object)): """ The base class for all events. @@ -39,7 +41,6 @@ class DelugeEvent(object): :type args: list """ - __metaclass__ = DelugeEventMetaClass def _get_name(self): return self.__class__.__name__ diff --git a/deluge/plugins/Blocklist/deluge/plugins/blocklist/common.py b/deluge/plugins/Blocklist/deluge/plugins/blocklist/common.py index 5a9d525a3..1d4fe9ae6 100644 --- a/deluge/plugins/Blocklist/deluge/plugins/blocklist/common.py +++ b/deluge/plugins/Blocklist/deluge/plugins/blocklist/common.py @@ -18,6 +18,7 @@ import os.path from functools import wraps from sys import exc_info +import six from pkg_resources import resource_filename @@ -44,7 +45,7 @@ def raises_errors_as(error): return func(self, *args, **kwargs) except Exception: (value, tb) = exc_info()[1:] - raise error, value, tb + six.reraise(error, value, tb) return wrapper return decorator diff --git a/deluge/ui/gtkui/common.py b/deluge/ui/gtkui/common.py index 8ba48d26a..c6622f1e0 100644 --- a/deluge/ui/gtkui/common.py +++ b/deluge/ui/gtkui/common.py @@ -10,12 +10,12 @@ from __future__ import unicode_literals import contextlib -import cPickle as pickle import logging import os import shutil import sys +import six.moves.cPickle as pickle from gobject import GError from gtk import SORT_ASCENDING, Menu, MenuItem, RadioMenuItem, SeparatorMenuItem, clipboard_get, icon_theme_get_default from gtk.gdk import COLORSPACE_RGB, SELECTION_PRIMARY, Pixbuf, pixbuf_new_from_file, pixbuf_new_from_file_at_size diff --git a/deluge/ui/gtkui/files_tab.py b/deluge/ui/gtkui/files_tab.py index 7cb31e437..94ee359a4 100644 --- a/deluge/ui/gtkui/files_tab.py +++ b/deluge/ui/gtkui/files_tab.py @@ -9,11 +9,11 @@ from __future__ import division, unicode_literals -import cPickle as pickle import logging import os.path import gtk +import six.moves.cPickle as pickle from gobject import TYPE_UINT64 from gtk.gdk import ACTION_DEFAULT, ACTION_MOVE, BUTTON1_MASK, keyval_name # pylint: disable=ungrouped-imports diff --git a/deluge/ui/translations_util.py b/deluge/ui/translations_util.py index 2491609bc..e82d0cbce 100644 --- a/deluge/ui/translations_util.py +++ b/deluge/ui/translations_util.py @@ -9,13 +9,14 @@ from __future__ import unicode_literals -import __builtin__ import gettext import locale import logging import os import sys +from six.moves import builtins + import deluge.common log = logging.getLogger(__name__) @@ -28,8 +29,8 @@ def set_dummy_trans(warn_msg=None): if warn_msg: log.warn('"%s" has been marked for translation, but translation is unavailable.', txt[0]) return txt[0] - __builtin__.__dict__['_'] = _func - __builtin__.__dict__['ngettext'] = __builtin__.__dict__['_n'] = _func + builtins.__dict__['_'] = _func + builtins.__dict__['ngettext'] = builtins.__dict__['_n'] = _func def get_translations_path(): @@ -127,7 +128,7 @@ def setup_translations(setup_gettext=True, setup_pygtk=False): kwargs = {} if not deluge.common.PY2 else {'unicode': True} gettext.install(domain, translations_path, names='ngettext', **kwargs) - __builtin__.__dict__['_n'] = __builtin__.__dict__['ngettext'] + builtins.__dict__['_n'] = builtins.__dict__['ngettext'] except Exception as ex: log.error('Unable to initialize gettext/locale!') log.exception(ex)