Patchwork [2,of,2] i18n: use unicode literal

login
register
mail settings
Submitter Gregory Szorc
Date June 26, 2016, 1:11 a.m.
Message ID <253e7a43ff2db74a5137.1466903479@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/15625/
State Accepted
Headers show

Comments

Gregory Szorc - June 26, 2016, 1:11 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1466901653 25200
#      Sat Jun 25 17:40:53 2016 -0700
# Node ID 253e7a43ff2db74a51370a95305d987d8a61c640
# Parent  62d74c821e87033fa5a7058b77f3db13744f309d
i18n: use unicode literal

Other parts of this expression are already using unicode literals.
We need this to make Python 3 happy and to avoid an implicit
conversion in Python 2.
Pierre-Yves David - June 26, 2016, 2:21 a.m.
On 06/26/2016 03:11 AM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1466901653 25200
> #      Sat Jun 25 17:40:53 2016 -0700
> # Node ID 253e7a43ff2db74a51370a95305d987d8a61c640
> # Parent  62d74c821e87033fa5a7058b77f3db13744f309d
> i18n: use unicode literal

okay, pushed.

Patch

diff --git a/mercurial/i18n.py b/mercurial/i18n.py
--- a/mercurial/i18n.py
+++ b/mercurial/i18n.py
@@ -73,17 +73,17 @@  def gettext(message):
     if message not in _msgcache:
         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 _ugettext(p) or '' for p in paragraphs])
+        u = u'\n\n'.join([p and _ugettext(p) or u'' for p in paragraphs])
         try:
             # encoding.tolocal cannot be used since it will first try to
             # decode the Unicode string. Calling u.decode(enc) really
             # means u.encode(sys.getdefaultencoding()).decode(enc). Since
             # the Python encoding defaults to 'ascii', this fails if the
             # translated string use non-ASCII characters.
             _msgcache[message] = u.encode(encoding.encoding, "replace")
         except LookupError: