From d138c947042f4088525a195dee1bf576b11119bb Mon Sep 17 00:00:00 2001 From: ZyX Date: Fri, 29 Aug 2014 21:05:54 +0400 Subject: [PATCH] Fix non-unicode error messages Ref #645 --- powerline/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/powerline/__init__.py b/powerline/__init__.py index d94329d2..529826ab 100644 --- a/powerline/__init__.py +++ b/powerline/__init__.py @@ -67,9 +67,15 @@ class PowerlineLogger(object): def _log(self, attr, msg, *args, **kwargs): prefix = kwargs.get('prefix') or self.prefix prefix = self.ext + ((':' + prefix) if prefix else '') + msg = safe_unicode(msg) if args or kwargs: + args = [safe_unicode(s) if isinstance(s, bytes) else s for s in args] + kwargs = dict(( + (k, safe_unicode(v) if isinstance(v, bytes) else v) + for k, v in kwargs.items() + )) msg = msg.format(*args, **kwargs) - msg = prefix + ':' + safe_unicode(msg) + msg = prefix + ':' + msg key = attr + ':' + prefix if msg != self.last_msgs.get(key): getattr(self.logger, attr)(msg)