mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-10-09 03:49:27 +00:00
json.loads() stupidly does not accept memoryview
This commit is contained in:
parent
50935b6c93
commit
5c9aa6a21a
2 changed files with 4 additions and 2 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue