# HG changeset patch # User Gregory Szorc # Date 1494699651 25200 # Node ID 1a3a08b5d4d572c9f7ef9a3e9592ff4b15014abf # Parent b306120844bf7e1f5aa2b7117b2245158b5c5e4f encoding: remove workaround for locale.getpreferredencoding() locale.getpreferredencoding() was buggy in OS X for Python <2.7. Since we no longer support Python <2.7, we no longer need this workaround. This essentially reverts 2be70ca17311. diff -r b306120844bf -r 1a3a08b5d4d5 mercurial/encoding.py --- a/mercurial/encoding.py Sat May 13 11:12:44 2017 -0700 +++ b/mercurial/encoding.py Sat May 13 11:20:51 2017 -0700 @@ -60,34 +60,9 @@ environ = dict((k.encode(u'utf-8'), v.encode(u'utf-8')) for k, v in os.environ.items()) # re-exports -def _getpreferredencoding(): - ''' - On darwin, getpreferredencoding ignores the locale environment and - always returns mac-roman. http://bugs.python.org/issue6202 fixes this - for Python 2.7 and up. This is the same corrected code for earlier - Python versions. - - However, we can't use a version check for this method, as some distributions - patch Python to fix this. Instead, we use it as a 'fixer' for the mac-roman - encoding, as it is unlikely that this encoding is the actually expected. - ''' - try: - locale.CODESET - except AttributeError: - # Fall back to parsing environment variables :-( - return locale.getdefaultlocale()[1] - - oldloc = locale.setlocale(locale.LC_CTYPE) - locale.setlocale(locale.LC_CTYPE, "") - result = locale.nl_langinfo(locale.CODESET) - locale.setlocale(locale.LC_CTYPE, oldloc) - - return result - _encodingfixers = { '646': lambda: 'ascii', 'ANSI_X3.4-1968': lambda: 'ascii', - 'mac-roman': _getpreferredencoding } try: