Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/encoding.py @ 30627:ce36fa9b140c
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.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Sat, 17 Dec 2016 23:55:25 +0530 |
parents | e4a6b439acc5 |
children | 067add650129 |
comparison
equal
deleted
inserted
replaced
30626:d7875bfbfccb | 30627:ce36fa9b140c |
---|---|
91 } | 91 } |
92 | 92 |
93 try: | 93 try: |
94 encoding = environ.get("HGENCODING") | 94 encoding = environ.get("HGENCODING") |
95 if not encoding: | 95 if not encoding: |
96 encoding = locale.getpreferredencoding() or 'ascii' | 96 encoding = locale.getpreferredencoding().encode('ascii') or 'ascii' |
97 encoding = _encodingfixers.get(encoding, lambda: encoding)() | 97 encoding = _encodingfixers.get(encoding, lambda: encoding)() |
98 except locale.Error: | 98 except locale.Error: |
99 encoding = 'ascii' | 99 encoding = 'ascii' |
100 encodingmode = environ.get("HGENCODINGMODE", "strict") | 100 encodingmode = environ.get("HGENCODINGMODE", "strict") |
101 fallbackencoding = 'ISO-8859-1' | 101 fallbackencoding = 'ISO-8859-1' |