From a1a7562bdb2db026ab9a3d9ba2d3858b1f8f1eba Mon Sep 17 00:00:00 2001 From: James Hilliard Date: Wed, 17 Sep 2025 18:59:21 -0600 Subject: [PATCH] Handle invalid unicode in json response --- pyasic/rpc/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyasic/rpc/base.py b/pyasic/rpc/base.py index 044a4fc2..c8adc7a4 100644 --- a/pyasic/rpc/base.py +++ b/pyasic/rpc/base.py @@ -253,10 +253,10 @@ If you are sure you want to use this command please use API.send_command("{comma # some json from the API returns with a null byte (\x00) on the end if data.endswith(b"\x00"): # handle the null byte - str_data = data.decode("utf-8")[:-1] + str_data = data.decode("utf-8", errors="replace")[:-1] else: # no null byte - str_data = data.decode("utf-8") + str_data = data.decode("utf-8", errors="replace") # fix an error with a btminer return having an extra comma that breaks json.loads() str_data = str_data.replace(",}", "}") # fix an error with a btminer return having a newline that breaks json.loads()