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:
@@ -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:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user