mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-11 18:32:12 +02:00
json.loads() stupidly does not accept memoryview
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user