zarr-python icon indicating copy to clipboard operation
zarr-python copied to clipboard

AttributeError: 'ZipStore' object has no attribute '_lock'

Open oelhammouchi opened this issue 1 month ago • 2 comments

Zarr version

v3.1.3

Numcodecs version

v0.16.3

Python Version

3.12.10

Operating System

Linux

Installation

using uv

Description

Calling the exists method on a ZipStore instance for an existing ZIP file raises the exception AttributeError: 'ZipStore' object has no attribute '_lock'. It seems this is because the method is not protected by a block

 if not self._is_open:
    self._sync_open()

as seen elsewhere in the code. If this was simply an omission it should be an easy fix, I can open a PR if you want.

Thanks a lot for the great library!

Steps to reproduce

# /// script
# requires-python = ">=3.11"
# dependencies = [
#   "zarr@git+https://github.com/zarr-developers/zarr-python.git@main",
# ]
# ///
#
# This script automatically imports the development branch of zarr to check for issues

from zarr.storage import ZipStore
from zipfile import ZipFile
import asyncio

ZipFile("/tmp/tmp.zip", "w").close()

async def main():
    with ZipStore("/tmp/tmp.zip", mode="r") as store:
        return await store.exists("somekey")

asyncio.run(main())

Additional output

No response

oelhammouchi avatar Nov 20 '25 12:11 oelhammouchi

sorry about this, and a PR fixing it would be great

d-v-b avatar Nov 20 '25 12:11 d-v-b

@d-v-b see #3593

oelhammouchi avatar Nov 21 '25 00:11 oelhammouchi