[PATCH 1 of 4] py3: make sure encoding.encoding is a bytes variable

Pulkit Goyal 7895pulkit at gmail.com
Sun Dec 18 07:01:31 EST 2016


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1481999125 -19800
#      Sat Dec 17 23:55:25 2016 +0530
# Node ID af87471131e2fecc9e6edeb2a5c2e155953da4bb
# Parent  1c8efe62f1f36fdf1a1bd6fcc5924cf557141d4a
py3: make sure encoding.encoding is a bytes variable

encoding.encoding returns unicodes when locale.getpreferredencoding() is used
to get the preferred encoding. This patch fixes that.

diff -r 1c8efe62f1f3 -r af87471131e2 mercurial/encoding.py
--- a/mercurial/encoding.py	Sat Dec 17 20:24:46 2016 +0530
+++ b/mercurial/encoding.py	Sat Dec 17 23:55:25 2016 +0530
@@ -93,7 +93,7 @@
 try:
     encoding = environ.get("HGENCODING")
     if not encoding:
-        encoding = locale.getpreferredencoding() or 'ascii'
+        encoding = locale.getpreferredencoding().encode('ascii') or 'ascii'
         encoding = _encodingfixers.get(encoding, lambda: encoding)()
 except locale.Error:
     encoding = 'ascii'


More information about the Mercurial-devel mailing list