Only convert to unicode when needed
authorLaurent Bachelier <laurent@bachelier.name>
Sun, 1 Dec 2013 19:13:23 +0000 (20:13 +0100)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 4 Dec 2013 00:33:53 +0000 (19:33 -0500)
Otherwise, it would crash if any unicode string was already
present.

Signed-off-by: Eric S. Raymond <esr@thyrsus.com>
irkerhook.py

index 35f305af37e6dbf3a2ff364399aa8b270ef36d69..c7c7b0d585ab9a9da8747ed9eba750323c2972bb 100755 (executable)
@@ -88,7 +88,8 @@ class Commit:
                     self.url = webview
             except IOError:
                 self.url = ""
-        return unicode(self.template % self.__dict__, "utf-8")
+        res = self.template % self.__dict__
+        return unicode(res, 'UTF-8') if not isinstance(res, unicode) else res
 
 class GenericExtractor:
     "Generic class for encapsulating data from a VCS."