diff --git a/deluge/path_chooser_common.py b/deluge/path_chooser_common.py index b84d78ef9..0f93feef6 100644 --- a/deluge/path_chooser_common.py +++ b/deluge/path_chooser_common.py @@ -12,6 +12,8 @@ from __future__ import unicode_literals import os +from deluge.common import PY2 + def is_hidden(filepath): def has_hidden_attribute(filepath): @@ -52,7 +54,10 @@ def get_completion_paths(args): def get_subdirs(dirname): try: - return os.walk(dirname).next()[1] + if PY2: + return os.walk(dirname).__next__[1] + else: + return next(os.walk(dirname))[1] except StopIteration: # Invalid dirname return [] diff --git a/deluge/ui/gtk3/common.py b/deluge/ui/gtk3/common.py index d05ad5d17..ae26ac85f 100644 --- a/deluge/ui/gtk3/common.py +++ b/deluge/ui/gtk3/common.py @@ -29,7 +29,7 @@ from gi.repository.Gtk import ( SortType, ) -from deluge.common import get_pixmap, osx_check, windows_check +from deluge.common import PY2, get_pixmap, osx_check, windows_check log = logging.getLogger(__name__) @@ -331,7 +331,10 @@ def load_pickled_state_file(filename): log.info('Opening %s for load: %s', filename, _filepath) try: with open(_filepath, 'rb') as _file: - state = pickle.load(_file) + if PY2: + state = pickle.load(_file) + else: + state = pickle.load(_file, encoding='utf8') except (IOError, pickle.UnpicklingError) as ex: log.warning('Unable to load %s: %s', _filepath, ex) else: