Ignore setlocale() failures on Linux as well

There are apparently some Linux systems that manage to bork their
locales out there. So just go on with the C locale on these systems.
This commit is contained in:
Kovid Goyal 2020-02-22 18:13:39 +05:30
parent 6d470e4da0
commit b54ffbefe4
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -233,22 +233,28 @@ def setup_environment(opts, args):
set_default_env(extra_env)
def _main():
with suppress(AttributeError): # python compiled without threading
sys.setswitchinterval(1000.0) # we have only a single python thread
def set_locale():
if is_macos:
ensure_macos_locale()
try:
locale.setlocale(locale.LC_ALL, '')
except Exception:
if not is_macos:
raise
log_error('Failed to set locale with LANG:', os.environ.get('LANG'))
os.environ.pop('LANG', None)
try:
locale.setlocale(locale.LC_ALL, '')
except Exception:
log_error('Failed to set locale with no LANG, ignoring')
log_error('Failed to set locale with no LANG')
def _main():
with suppress(AttributeError): # python compiled without threading
sys.setswitchinterval(1000.0) # we have only a single python thread
try:
set_locale()
except Exception:
log_error('Failed to set locale, ignoring')
# Ensure the correct kitty is in PATH
rpath = sys._xoptions.get('bundle_exe_dir')