Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/2807.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix pickling for ZipStore
3 changes: 2 additions & 1 deletion src/zarr/storage/_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ async def _open(self) -> None:
self._sync_open()

def __getstate__(self) -> dict[str, Any]:
state = self.__dict__
# We need a copy to not modify the state of the original store
state = self.__dict__.copy()
for attr in ["_zf", "_lock"]:
state.pop(attr, None)
return state
Expand Down
8 changes: 7 additions & 1 deletion src/zarr/testing/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,16 @@ def test_store_eq(self, store: S, store_kwargs: dict[str, Any]) -> None:
store2 = self.store_cls(**store_kwargs)
assert store == store2

def test_serializable_store(self, store: S) -> None:
async def test_serializable_store(self, store: S) -> None:
new_store: S = pickle.loads(pickle.dumps(store))
assert new_store == store
assert new_store.read_only == store.read_only
# quickly roundtrip data to a key to test that new store works
data_buf = self.buffer_cls.from_bytes(b"\x01\x02\x03\x04")
key = "foo"
await store.set(key, data_buf)
observed = await store.get(key, prototype=default_buffer_prototype())
assert_bytes_equal(observed, data_buf)

def test_store_read_only(self, store: S) -> None:
assert not store.read_only
Expand Down