changeset 21746:2d47d81c79fb

i18n: explicitly decode paragraphs This was triggering an exception when the default encoding was disabled.
author Matt Mackall <mpm@selenic.com>
date Thu, 12 Jun 2014 14:40:45 -0500
parents 4c62478be2ea
children fecead61d222
files mercurial/i18n.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/i18n.py	Fri Jun 13 14:14:02 2014 -0500
+++ b/mercurial/i18n.py	Thu Jun 12 14:40:45 2014 -0500
@@ -36,7 +36,11 @@
     if message is None:
         return message
 
-    paragraphs = message.split('\n\n')
+    if type(message) is unicode:
+        # goofy unicode docstrings in test
+        paragraphs = message.split(u'\n\n')
+    else:
+        paragraphs = [p.decode("ascii") for p in message.split('\n\n')]
     # Be careful not to translate the empty string -- it holds the
     # meta data of the .po file.
     u = u'\n\n'.join([p and t.ugettext(p) or '' for p in paragraphs])