[GTK3] Fix Python 3 issues
In Python 3 builtin next function instead of the next method. Unpickling with translated strings in state file causes ascii decode error so ensure UTF-8 encoding is specified.
This commit is contained in:
parent
194129c027
commit
8285b226eb
|
@ -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 []
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue