From 173404229381d580b7ed601897087cba0a2e9b6e Mon Sep 17 00:00:00 2001 From: SomberNight Date: Tue, 23 Jan 2024 01:49:04 +0000 Subject: [PATCH] jsondb: raise when trying to store sets in the db Some generic protection to prevent bugs similar to what was just fixed in prev commits. related https://github.com/spesmilo/electrum/issues/8842 --- electrum/json_db.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/electrum/json_db.py b/electrum/json_db.py index 1c1841bd8..b88ba4f56 100644 --- a/electrum/json_db.py +++ b/electrum/json_db.py @@ -159,6 +159,9 @@ class StoredDict(dict): # convert lists if isinstance(v, list): v = StoredList(v, self.db, self.path + [key]) + # reject sets. they do not work well with jsonpatch + if isinstance(v, set): + raise Exception(f"Do not store sets inside jsondb. path={self.path!r}") # set item dict.__setitem__(self, key, v) if self.db and patch: