You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
User-provided attributes dictionary is mutated by the public API #4059
When creating a Zarr group or array with a user-provided attributes dictionary, the original dictionary gets mutated when the user subsequently modifies attributes via the public API (attrs.setitem, attrs.put, or del attrs[key]).
Steps to reproduce
# /// script# requires-python = ">=3.12"# dependencies = [# "zarr@git+https://github.com/zarr-developers/zarr-python.git@main",# ]# ///## This script automatically imports the development branch of zarr to check for issuesimportzarrinit_dict= {"foo": "bar"}
user_attrs=dict(init_dict)
print("User's dict before passing to Zarr:", user_attrs)
g=zarr.group(attributes=user_attrs)
g.attrs["new_key"] ="new_value"print("User's dict after passing to Zarr:", user_attrs)
print("Expected: ", init_dict)
assertuser_attrs==init_dict, "FAIL: Original dict mutated by"zarr.print_debug_info()
Additional output
There is a key called cache_attrs under zarr.group() which is not yet implemented. Is there a reason to pursue that over just copying the attributes which user provides?
Activity
d-v-b commentedon Jun 11, 2026
that's an unpleasant bug. We should be copying the user input.