diff --git a/kitty/boss.py b/kitty/boss.py index fe2a4dafe..e0a7c5e98 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -775,7 +775,7 @@ class Boss: cmd_prefix = b'\x1bP@kitty-cmd' terminator = b'\x1b\\' if msg_bytes.startswith(cmd_prefix) and msg_bytes.endswith(terminator): - cmd = memoryview(msg_bytes[len(cmd_prefix):-len(terminator)]) + cmd = memoryview(msg_bytes)[len(cmd_prefix):-len(terminator)] response = self._handle_remote_command(cmd, peer_id=peer_id) if response is None: return None diff --git a/kitty/remote_control.py b/kitty/remote_control.py index 1c168d5b4..f24396db3 100644 --- a/kitty/remote_control.py +++ b/kitty/remote_control.py @@ -53,8 +53,10 @@ def encode_response_for_peer(response: Any) -> bytes: def parse_cmd(serialized_cmd: memoryview, encryption_key: EllipticCurveKey) -> Dict[str, Any]: + # See https://github.com/python/cpython/issues/74379 for why we cant use + # memoryview directly :(( try: - pcmd = json.loads(serialized_cmd) + pcmd = json.loads(bytes(serialized_cmd)) except Exception: return {} if not isinstance(pcmd, dict) or 'version' not in pcmd: