[PATCH 02 of 10] py3: use unicode literals in i18n.py

Yuya Nishihara yuya at tcha.org
Wed Aug 3 09:27:27 EDT 2016


On Wed, 03 Aug 2016 01:57:24 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit at gmail.com>
> # Date 1470162549 -19800
> #      Tue Aug 02 23:59:09 2016 +0530
> # Node ID 9c65985526ca8aff6bdb9234bbf584837ab15de8
> # Parent  c03543a126719097a1a61c8e5ef5fcb222262315
> py3: use unicode literals in i18n.py
> 
> diff -r c03543a12671 -r 9c65985526ca mercurial/i18n.py
> --- a/mercurial/i18n.py	Tue Aug 02 23:39:45 2016 +0530
> +++ b/mercurial/i18n.py	Tue Aug 02 23:59:09 2016 +0530
> @@ -46,8 +46,11 @@
>  _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')

datapath is bytes.

> @@ -92,10 +95,10 @@
>      return _msgcache[message]
>  
>  def _plain():
> -    if 'HGPLAIN' not in os.environ and 'HGPLAINEXCEPT' not in os.environ:
> +    if u'HGPLAIN' not in os.environ and u'HGPLAINEXCEPT' not in os.environ:
>          return False
> -    exceptions = os.environ.get('HGPLAINEXCEPT', '').strip().split(',')
> -    return 'i18n' not in exceptions
> +    exceptions = os.environ.get(u'HGPLAINEXCEPT', u'').strip().split(u',')
> +    return u'i18n' not in exceptions

Same here. os.environ is a dict of bytes in Python 2 world.


More information about the Mercurial-devel mailing list