From 2427d2d9dac3fa4eaaf00c5369d73517ccbdd681 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 7 May 2022 20:43:10 +0530 Subject: [PATCH] Workaround Apple's "hardening" breaking the platform module Fix #5065 Fix #5051 --- kitty/utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kitty/utils.py b/kitty/utils.py index 0b35bb72a..78a482c85 100644 --- a/kitty/utils.py +++ b/kitty/utils.py @@ -974,8 +974,13 @@ def path_from_osc7_url(url: str) -> str: @run_once def macos_version() -> Tuple[int, ...]: - import platform - return tuple(map(int, platform.mac_ver()[0].split('.'))) + # platform.mac_ver does not work thanks to Apple's stupid "hardening", so just use sw_vers + import subprocess + try: + o = subprocess.check_output(['sw_vers', '-productVersion'], stderr=subprocess.STDOUT).decode() + except Exception: + return 0, 0, 0 + return tuple(map(int, o.strip().split('.'))) @lru_cache(maxsize=2)