aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/webhooks.py
diff options
context:
space:
mode:
authorTomasz Kramkowski <tomasz@kramkow.ski>2025-08-06 17:58:10 +0100
committerTomasz Kramkowski <tomasz@kramkow.ski>2025-08-06 18:42:41 +0100
commit8eab4299c93014613dbadfee6770535b99d48746 (patch)
tree25f2a82d41ec7f78724b4821040873a83c64f9ff /klippy/webhooks.py
parent581208b2ffeeb2a2128aee0741fa3fd9e46358e2 (diff)
downloadkutter-8eab4299c93014613dbadfee6770535b99d48746.tar.gz
kutter-8eab4299c93014613dbadfee6770535b99d48746.tar.xz
kutter-8eab4299c93014613dbadfee6770535b99d48746.zip
Remove python2 support (first party)
Diffstat (limited to 'klippy/webhooks.py')
-rw-r--r--klippy/webhooks.py23
1 files changed, 1 insertions, 22 deletions
diff --git a/klippy/webhooks.py b/klippy/webhooks.py
index 1a471a93..64abe2b2 100644
--- a/klippy/webhooks.py
+++ b/klippy/webhooks.py
@@ -11,32 +11,11 @@ try:
except ImportError:
import json
- # Json decodes strings as unicode types in Python 2.x. This doesn't
- # play well with some parts of Klipper (particularly displays), so we
- # need to create an object hook. This solution borrowed from:
- #
- # https://stackoverflow.com/questions/956867/
- #
- json_loads_byteify = None
- if sys.version_info.major < 3:
-
- def json_loads_byteify(data, ignore_dicts=False):
- if isinstance(data, unicode):
- return data.encode("utf-8")
- if isinstance(data, list):
- return [json_loads_byteify(i, True) for i in data]
- if isinstance(data, dict) and not ignore_dicts:
- return {
- json_loads_byteify(k, True): json_loads_byteify(v, True)
- for k, v in data.items()
- }
- return data
-
def json_dumps(obj):
return json.dumps(obj, separators=(",", ":")).encode()
def json_loads(data):
- return json.loads(data, object_hook=json_loads_byteify)
+ return json.loads(data)
else:
json_dumps = msgspec.json.encode