Skip to content

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

@oelhammouchi

Description

@oelhammouchi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPotential issues with the zarr-python library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions