comparison mercurial/i18n.py @ 40254:dd83aafdb64a

py3: get around unicode docstrings in test-encoding-textwrap.t and test-help.t On Python 3, docstrings are converted back to utf-8 bytes, which practically disables the "if type(message) is pycompat.unicode" hack in gettext(). Let's add one more workaround for the Py3 path.
author Yuya Nishihara <yuya@tcha.org>
date Fri, 12 Oct 2018 19:25:08 +0200
parents 79dd61a4554f
children 2372284d9457
comparison
equal deleted inserted replaced
40253:682f73fa924a 40254:dd83aafdb64a
73 if message not in cache: 73 if message not in cache:
74 if type(message) is pycompat.unicode: 74 if type(message) is pycompat.unicode:
75 # goofy unicode docstrings in test 75 # goofy unicode docstrings in test
76 paragraphs = message.split(u'\n\n') 76 paragraphs = message.split(u'\n\n')
77 else: 77 else:
78 paragraphs = [p.decode("ascii") for p in message.split('\n\n')] 78 # should be ascii, but we have unicode docstrings in test, which
79 # are converted to utf-8 bytes on Python 3.
80 paragraphs = [p.decode("utf-8") for p in message.split('\n\n')]
79 # Be careful not to translate the empty string -- it holds the 81 # Be careful not to translate the empty string -- it holds the
80 # meta data of the .po file. 82 # meta data of the .po file.
81 u = u'\n\n'.join([p and _ugettext(p) or u'' for p in paragraphs]) 83 u = u'\n\n'.join([p and _ugettext(p) or u'' for p in paragraphs])
82 try: 84 try:
83 # encoding.tolocal cannot be used since it will first try to 85 # encoding.tolocal cannot be used since it will first try to