-
Notifications
You must be signed in to change notification settings - Fork 632
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix: fix
__getattr__()
for KeyMapDB
- the reference to `self._db` inside `__getattr__` was resulting in a segfault
- Loading branch information
1 parent
fb28fa4
commit 13b423a
Showing
3 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix ``__getattr__()`` for ``KeyMapDB`` and thus allow it to be copied / deep copied. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import copy | ||
|
||
from eth.db.backends.memory import ( | ||
MemoryDB, | ||
) | ||
from eth.db.hash_trie import ( | ||
HashTrie, | ||
) | ||
|
||
|
||
def test_keymap_db_can_be_copied_and_deep_copied(): | ||
hash_trie = HashTrie(MemoryDB({b"a": b"1", b"b": b"2"})) | ||
|
||
copied_hash_trie = copy.copy(hash_trie) | ||
deep_copied_hash_trie = copy.deepcopy(hash_trie) | ||
|
||
assert hash_trie._db == copied_hash_trie._db | ||
assert hash_trie._db == deep_copied_hash_trie._db | ||
|
||
hash_trie[b"c"] = b"3" | ||
assert b"c" in hash_trie | ||
assert b"c" not in deep_copied_hash_trie |