From 8e26c252fa9e4bec99921dfb3eacd6bf126bed49 Mon Sep 17 00:00:00 2001 From: fdev31 Date: Fri, 27 Sep 2024 21:47:13 +0200 Subject: [PATCH] be more robust to encoding errors --- pyprland/command.py | 2 +- pyprland/ipc.py | 3 ++- pyprland/version.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pyprland/command.py b/pyprland/command.py index 7cc323d..898cc12 100644 --- a/pyprland/command.py +++ b/pyprland/command.py @@ -233,7 +233,7 @@ async def read_events_loop(self) -> None: """Consume the event loop and calls corresponding handlers.""" while not self.stopped: try: - data = (await self.event_reader.readline()).decode() + data = (await self.event_reader.readline()).decode(errors="replace") except RuntimeError: self.log.exception("Aborting event loop") return diff --git a/pyprland/ipc.py b/pyprland/ipc.py index 0831cb1..1e986c6 100644 --- a/pyprland/ipc.py +++ b/pyprland/ipc.py @@ -85,7 +85,8 @@ async def _get_response(command: bytes, logger: Logger) -> JSONResponse: reader_data = await reader.read() writer.close() await writer.wait_closed() - return json.loads(reader_data) # type: ignore + decoded_data = reader_data.decode("utf-8", errors="replace") + return json.loads(decoded_data) # type: ignore @retry_on_reset diff --git a/pyprland/version.py b/pyprland/version.py index 635555a..458de15 100644 --- a/pyprland/version.py +++ b/pyprland/version.py @@ -1,3 +1,3 @@ """Package version.""" -VERSION = "2.4.0-49" +VERSION = "2.4.0-52"