compat: back out a25343d16ebe (initialize LC_CTYPE locale on all Python ...)
authorManuel Jacob <me@manueljacob.de>
Sun, 28 Jun 2020 17:52:29 +0200
changeset 45018 f2dc337117b9
parent 45017 a65c60f3280e
child 45019 4a503c1b664a
compat: back out a25343d16ebe (initialize LC_CTYPE locale on all Python ...) As Yuya Nishihara pointed out, setting LC_CTYPE changes the behavior of some str methods on Python 2.
mercurial/pycompat.py
--- a/mercurial/pycompat.py	Sun Jun 28 17:49:14 2020 +0200
+++ b/mercurial/pycompat.py	Sun Jun 28 17:52:29 2020 +0200
@@ -13,7 +13,6 @@
 import getopt
 import inspect
 import json
-import locale
 import os
 import shlex
 import sys
@@ -94,26 +93,6 @@
     return _rapply(f, xs)
 
 
-# Passing the '' locale means that the locale should be set according to the
-# user settings (environment variables).
-# Python sometimes avoids setting the global locale settings. When interfacing
-# with C code (e.g. the curses module or the Subversion bindings), the global
-# locale settings must be initialized correctly. Python 2 does not initialize
-# the global locale settings on interpreter startup. Python 3 sometimes
-# initializes LC_CTYPE, but not consistently at least on Windows. Therefore we
-# explicitly initialize it to get consistent behavior if it's not already
-# initialized. Since CPython commit 177d921c8c03d30daa32994362023f777624b10d,
-# LC_CTYPE is always initialized. If we require Python 3.8+, we should re-check
-# if we can remove this code.
-if locale.setlocale(locale.LC_CTYPE, None) == 'C':
-    try:
-        locale.setlocale(locale.LC_CTYPE, '')
-    except locale.Error:
-        # The likely case is that the locale from the environment variables is
-        # unknown.
-        pass
-
-
 if ispy3:
     import builtins
     import codecs