Browse Source

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.
master
SomberNight 2 years ago
parent
commit
5b9b616146
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 4
      electrum/simple_config.py

4
electrum/simple_config.py

@ -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:

Loading…
Cancel
Save