From 57dfc379aef43bd4b95c88ca5b2467afb9aa9a2e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 14 Aug 2022 22:11:33 +0530 Subject: [PATCH] Fix cocoa being loaded before the fork on macOS --- kitty/main.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/kitty/main.py b/kitty/main.py index 3045ad418..bdf46dd64 100644 --- a/kitty/main.py +++ b/kitty/main.py @@ -357,11 +357,6 @@ def set_locale() -> None: def _main() -> None: running_in_kitty(True) - try: - set_locale() - except Exception: - log_error('Failed to set locale, ignoring') - args = sys.argv[1:] if is_macos and os.environ.pop('KITTY_LAUNCHED_BY_LAUNCH_SERVICES', None) == '1': os.chdir(os.path.expanduser('~')) @@ -407,6 +402,13 @@ def _main() -> None: prewarm = fork_prewarm_process(opts) if prewarm is None: raise SystemExit(1) + + # set_locale on macOS uses cocoa APIs when LANG is not set, so we have to + # call it after the fork + try: + set_locale() + except Exception: + log_error('Failed to set locale, ignoring') with suppress(AttributeError): # python compiled without threading sys.setswitchinterval(1000.0) # we have only a single python thread init_glfw(opts, cli_opts.debug_keyboard, cli_opts.debug_rendering)