[PATCH 6 of 9 V2] i18n: use unicode literals to appease Python 3

Yuya Nishihara yuya at tcha.org
Sun Jul 3 13:27:08 UTC 2016


On Sat, 25 Jun 2016 14:11:20 -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1466887325 25200
> #      Sat Jun 25 13:42:05 2016 -0700
> # Node ID 5ca58f193ff2f421ce7b7c6b577e0cf7d31758ab
> # Parent  3803d2501ef928a177fa09df612da6a09e9f42e6
> i18n: use unicode literals to appease Python 3

I just found a problem while scanning this series, I haven't reviewed the
series carefully. According to the discussion on IRC, we agree this is the
best way to avoid bulk rewriting of ''s to b''s, but we are not confident
that this will never be a future maintenance burden.

> +++ b/mercurial/i18n.py
> @@ -41,18 +41,21 @@ if (os.name == 'nt'
>          _languages = [locale.windows_locale[langid]]
>      except (ImportError, AttributeError, KeyError):
>          # ctypes not found or unknown langid
>          pass
>  
>  _ugettext = None
>  
>  def setdatapath(datapath):
> -    localedir = os.path.join(datapath, 'locale')
> -    t = gettextmod.translation('hg', localedir, _languages, fallback=True)
> +    localedir = os.path.join(datapath, u'locale')

Concatenating bytes and unicode could raise UnicodeDecodeError on Python 2.


More information about the Mercurial-devel mailing list