From 304d42d4c271b74ac546e5814b6329aed395e331 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 16 Jul 2017 22:49:05 +0530 Subject: [PATCH] Fix #93 Ignore invalid language names returned by the coca framework on macOS --- kitty/main.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kitty/main.py b/kitty/main.py index 2a796b3a9..946e772aa 100644 --- a/kitty/main.py +++ b/kitty/main.py @@ -241,7 +241,17 @@ def ensure_osx_locale(): def main(): if isosx: ensure_osx_locale() - locale.setlocale(locale.LC_ALL, '') + try: + locale.setlocale(locale.LC_ALL, '') + except Exception: + if not isosx: + raise + print('Failed to set locale with LANG:', os.environ.get('LANG'), file=sys.stderr) + os.environ.pop('LANG') + try: + locale.setlocale(locale.LC_ALL, '') + except Exception: + print('Failed to set locale with no LANG, ignoring', file=sys.stderr) if os.environ.pop('KITTY_LAUNCHED_BY_LAUNCH_SERVICES', None) == '1' and getattr(sys, 'frozen', True): os.chdir(os.path.expanduser('~'))