From 4972d1da57a1ecbc0a4f8c39567aee8b71d809ef Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Tue, 17 Mar 2015 22:02:34 +0100 Subject: [PATCH] Decode all strerror-based exception messages I reviewed all instances of: - EnvironmentError - OSError - IOError - socket.error In most cases, we already used encoding.locale_decode(). The case fixed in mopidy/utils/network.py fixes #971. The case fixed in mopidy/utils/path.py might be triggered during a local library scan. --- mopidy/utils/network.py | 3 ++- mopidy/utils/path.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mopidy/utils/network.py b/mopidy/utils/network.py index ce02ef0e..f55649e3 100644 --- a/mopidy/utils/network.py +++ b/mopidy/utils/network.py @@ -199,7 +199,8 @@ class Connection(object): except socket.error as e: if e.errno in (errno.EWOULDBLOCK, errno.EINTR): return data - self.stop('Unexpected client error: %s' % e) + self.stop( + 'Unexpected client error: %s' % encoding.locale_decode(e)) return b'' def enable_timeout(self): diff --git a/mopidy/utils/path.py b/mopidy/utils/path.py index 0c0d6676..8bca275d 100644 --- a/mopidy/utils/path.py +++ b/mopidy/utils/path.py @@ -12,6 +12,7 @@ import glib from mopidy import compat, exceptions from mopidy.compat import queue +from mopidy.utils import encoding logger = logging.getLogger(__name__) @@ -157,7 +158,8 @@ def _find_worker(relative, follow, done, work, results, errors): errors[path] = exceptions.FindError('Not a file or directory.') except OSError as e: - errors[path] = exceptions.FindError(e.strerror, e.errno) + errors[path] = exceptions.FindError( + encoding.locale_decode(e.strerror), e.errno) finally: work.task_done()