changeset 32316:1a3a08b5d4d5

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.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 13 May 2017 11:20:51 -0700
parents b306120844bf
children 80e3002cd29e
files mercurial/encoding.py
diffstat 1 files changed, 0 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- 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: