1
0

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 "<stdin>", line 1, in <module>
  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.
This commit is contained in:
SomberNight
2023-07-11 14:50:09 +00:00
parent b1b2190f0a
commit 5b9b616146

View File

@@ -89,6 +89,10 @@ class ConfigVar(property):
def __repr__(self):
return f"<ConfigVar key={self._key!r}>"
def __deepcopy__(self, memo):
cv = ConfigVar(self._key, default=self._default, type_=self._type)
return cv
class ConfigVarWithConfig: