Re: [PATCH] py3: get around unicode docstrings in test-encoding-textwrap.t and test-help.t

2018-10-13 Thread Augie Fackler


> On Oct 12, 2018, at 19:36, Yuya Nishihara  wrote:
> 
> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1539365108 -7200
> #  Fri Oct 12 19:25:08 2018 +0200
> # Node ID fc11940aeb629be72d144cf77cea245c3369c850
> # Parent  ba70e3acf58a6a929a23f5b80e08c98a4ad776d4
> py3: get around unicode docstrings in test-encoding-textwrap.t and test-help.t

queued, thanks
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH] py3: get around unicode docstrings in test-encoding-textwrap.t and test-help.t

2018-10-12 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1539365108 -7200
#  Fri Oct 12 19:25:08 2018 +0200
# Node ID fc11940aeb629be72d144cf77cea245c3369c850
# Parent  ba70e3acf58a6a929a23f5b80e08c98a4ad776d4
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.

diff --git a/mercurial/i18n.py b/mercurial/i18n.py
--- a/mercurial/i18n.py
+++ b/mercurial/i18n.py
@@ -75,7 +75,9 @@ def gettext(message):
 # goofy unicode docstrings in test
 paragraphs = message.split(u'\n\n')
 else:
-paragraphs = [p.decode("ascii") for p in message.split('\n\n')]
+# should be ascii, but we have unicode docstrings in test, which
+# are converted to utf-8 bytes on Python 3.
+paragraphs = [p.decode("utf-8") 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 _ugettext(p) or u'' for p in paragraphs])
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel