浏览代码

fix(entity): json.decode can raise TypeError

When decoding json attributes, if the value is null or a non-string value, json.decode
raises TypeError rather than JSONDecodeError.

Issue #6352
Jason Rumney 1 月之前
父节点
当前提交
cbe214cbf6
共有 1 个文件被更改,包括 1 次插入 和 1 次删除
  1. 1 1
      custom_components/tuya_local/entity.py

+ 1 - 1
custom_components/tuya_local/entity.py

@@ -107,7 +107,7 @@ class TuyaLocalEntity:
                 if a.rawtype == "json":
                     try:
                         value = json.loads(value)
-                    except json.JSONDecodeError:
+                    except json.JSONDecodeError, TypeError:
                         if value is not None:
                             _LOGGER.warning(
                                 "Failed to decode JSON for attribute %s: %s",