From b54ffbefe4c462a670b66284cb825da92ed44990 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 22 Feb 2020 18:13:39 +0530 Subject: [PATCH] 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. --- kitty/main.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/kitty/main.py b/kitty/main.py index 33f3b8f55..68cbb973d 100644 --- a/kitty/main.py +++ b/kitty/main.py @@ -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')