tconfig: reject non-json-serialisable writes - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 6958c0ccc3d97edfb7f8504f27270182cb3abcfa DIR parent ef2a6359e4521cef4302486a2b9844814938babf HTML Author: SomberNight <somber.night@protonmail.com> Date: Sun, 21 Oct 2018 14:58:55 +0200 config: reject non-json-serialisable writes see #4788 Diffstat: M electrum/simple_config.py | 6 ++++++ M electrum/storage.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) --- DIR diff --git a/electrum/simple_config.py b/electrum/simple_config.py t@@ -140,6 +140,12 @@ class SimpleConfig(PrintError): if not self.is_modifiable(key): self.print_stderr("Warning: not changing config key '%s' set on the command line" % key) return + try: + json.dumps(key) + json.dumps(value) + except: + self.print_error(f"json error: cannot save {repr(key)} ({repr(value)})") + return self._set_key_in_user_config(key, value, save) def _set_key_in_user_config(self, key, value, save=True): DIR diff --git a/electrum/storage.py b/electrum/storage.py t@@ -90,7 +90,7 @@ class JsonDB(PrintError): json.dumps(key, cls=util.MyEncoder) json.dumps(value, cls=util.MyEncoder) except: - self.print_error("json error: cannot save", key) + self.print_error(f"json error: cannot save {repr(key)} ({repr(value)})") return with self.db_lock: if value is not None: