Workaround for Python 3.11 breaking sys._xoptions

Apparently in Python-land its acceptable behavior to break backward
compatibility with documented interfaces on a whim. Bloody joke.
https://github.com/python/cpython/pull/28823

Fixes #5223
This commit is contained in:
Kovid Goyal
2022-06-23 08:44:34 +05:30
parent 5673359be2
commit f023f047ff
6 changed files with 33 additions and 44 deletions
+1 -1
View File
@@ -242,7 +242,7 @@ class Child:
def final_env(self) -> Dict[str, str]:
from kitty.options.utils import DELETE_ENV_VAR
env = default_env().copy()
if is_macos and env.get('LC_CTYPE') == 'UTF-8' and not sys._xoptions.get(
if is_macos and env.get('LC_CTYPE') == 'UTF-8' and not getattr(sys, 'kitty_run_data').get(
'lc_ctype_before_python') and not getattr(default_env, 'lc_ctype_set_by_user', False):
del env['LC_CTYPE']
env.update(self.env)
+2 -2
View File
@@ -29,7 +29,7 @@ is_macos: bool = 'darwin' in _plat
is_freebsd: bool = 'freebsd' in _plat
is_running_from_develop: bool = False
if getattr(sys, 'frozen', False):
extensions_dir: str = getattr(sys, 'kitty_extensions_dir')
extensions_dir: str = getattr(sys, 'kitty_run_data')['extensions_dir']
def get_frozen_base() -> str:
global is_running_from_develop
@@ -61,7 +61,7 @@ else:
@run_once
def kitty_exe() -> str:
rpath = sys._xoptions.get('bundle_exe_dir')
rpath = getattr(sys, 'kitty_run_data').get('bundle_exe_dir')
if not rpath:
items = os.environ.get('PATH', '').split(os.pathsep) + [os.path.join(kitty_base_dir, 'kitty', 'launcher')]
seen: Set[str] = set()
+1 -1
View File
@@ -159,7 +159,7 @@ def setup_openssl_environment() -> None:
# many systems come with no certificates in a useable form or have various
# locations for the certificates.
d = os.path.dirname
ext_dir: str = getattr(sys, 'kitty_extensions_dir')
ext_dir: str = getattr(sys, 'kitty_run_data')['extensions_dir']
if 'darwin' in sys.platform.lower():
cert_file = os.path.join(d(d(d(ext_dir))), 'cacert.pem')
else:
+3 -2
View File
@@ -305,11 +305,12 @@ def prepend_if_not_present(path: str, paths_serialized: str) -> str:
def ensure_kitty_in_path() -> None:
# Ensure the correct kitty is in PATH
rpath = sys._xoptions.get('bundle_exe_dir')
krd = getattr(sys, 'kitty_run_data')
rpath = krd.get('bundle_exe_dir')
if not rpath:
return
if rpath:
modify_path = is_macos or getattr(sys, 'frozen', False) or sys._xoptions.get('kitty_from_source') == '1'
modify_path = is_macos or getattr(sys, 'frozen', False) or krd.get('from_source')
existing = shutil.which('kitty')
if modify_path or not existing:
env_path = os.environ.get('PATH', '')