From 5b9b6161465e7843ce1bcc918ff7d722035aba7f Mon Sep 17 00:00:00 2001 From: SomberNight Date: Tue, 11 Jul 2023 14:50:09 +0000 Subject: [PATCH] simple_config: allow deepcopy-ing ConfigVars Was getting error: ``` >>> import copy >>> from electrum.simple_config import SimpleConfig >>> copy.deepcopy(SimpleConfig.EXPERIMENTAL_LN_FORWARD_PAYMENTS) Traceback (most recent call last): File "", line 1, in File "...\Python\Python310\lib\copy.py", line 161, in deepcopy rv = reductor(4) TypeError: cannot pickle 'ConfigVar' object ``` This is useful in tests/test_lnpeer.py, to deepcopy the GRAPH_DEFINITIONS dict. --- electrum/simple_config.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/electrum/simple_config.py b/electrum/simple_config.py index dedb93b4d..43f835a5e 100644 --- a/electrum/simple_config.py +++ b/electrum/simple_config.py @@ -89,6 +89,10 @@ class ConfigVar(property): def __repr__(self): return f"" + def __deepcopy__(self, memo): + cv = ConfigVar(self._key, default=self._default, type_=self._type) + return cv + class ConfigVarWithConfig: