diff --git a/deluge/ui/gtk3/common.py b/deluge/ui/gtk3/common.py index 24530dcab..ddb52720c 100644 --- a/deluge/ui/gtk3/common.py +++ b/deluge/ui/gtk3/common.py @@ -34,6 +34,17 @@ from deluge.common import PY2, get_pixmap, osx_check, windows_check log = logging.getLogger(__name__) +def cmp(x, y): + """Replacement for built-in function cmp that was removed in Python 3. + + Compare the two objects x and y and return an integer according to + the outcome. The return value is negative if x < y, zero if x == y + and strictly positive if x > y. + """ + + return (x > y) - (x < y) + + def create_blank_pixbuf(size=16): pix = Pixbuf.new(Colorspace.RGB, True, 8, size, size) pix.fill(0x0) diff --git a/deluge/ui/gtk3/listview.py b/deluge/ui/gtk3/listview.py index 78570f12d..ef328a8c2 100644 --- a/deluge/ui/gtk3/listview.py +++ b/deluge/ui/gtk3/listview.py @@ -15,7 +15,7 @@ from gi.repository import GObject, Gtk from deluge.common import PY2, decode_bytes -from .common import load_pickled_state_file, save_pickled_state_file +from .common import cmp, load_pickled_state_file, save_pickled_state_file log = logging.getLogger(__name__) diff --git a/deluge/ui/gtk3/torrentview.py b/deluge/ui/gtk3/torrentview.py index fad9526ba..0529ebed2 100644 --- a/deluge/ui/gtk3/torrentview.py +++ b/deluge/ui/gtk3/torrentview.py @@ -23,6 +23,7 @@ import deluge.component as component from deluge.ui.client import client from . import torrentview_data_funcs as funcs +from .common import cmp from .listview import ListView from .removetorrentdialog import RemoveTorrentDialog