[PATCH 01 of 10] py3: use unicode literals in encoding.py

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


On Wed, 03 Aug 2016 01:57:23 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit at gmail.com>
> # Date 1470161385 -19800
> #      Tue Aug 02 23:39:45 2016 +0530
> # Node ID c03543a126719097a1a61c8e5ef5fcb222262315
> # Parent  73ff159923c1f05899c27238409ca398342d9ae0
> py3: use unicode literals in encoding.py

>  try:
> -    encoding = os.environ.get("HGENCODING")
> +    encoding = os.environ.get(u"HGENCODING")
>      if not encoding:
> -        encoding = locale.getpreferredencoding() or 'ascii'
> +        encoding = locale.getpreferredencoding() or u'ascii'
>          encoding = _encodingfixers.get(encoding, lambda: encoding)()
>  except locale.Error:
> -    encoding = 'ascii'
> -encodingmode = os.environ.get("HGENCODINGMODE", "strict")
> -fallbackencoding = 'ISO-8859-1'
> +    encoding = u'ascii'
> +encodingmode = os.environ.get(u"HGENCODINGMODE", u"strict")
> +fallbackencoding = u'ISO-8859-1'

Try

  $ LC_MESSAGES=fr_FR.UTF-8 hg help -v version

We should never export unicode as a public API. Otherwise we would get in
trouble. unicode/bytes divergence is hard for humans.


More information about the Mercurial-devel mailing list