Skip to content

Commit 88bf001

Browse files
jeromekelleheranandtrex
authored andcommitted
Ensures that get_codec doesn't modify its argument.
Closes zarr-developers#78.
1 parent cd3083e commit 88bf001

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

numcodecs/registry.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def get_codec(config):
2929
Zlib(level=1)
3030
3131
"""
32+
config = dict(config)
3233
codec_id = config.pop('id', None)
3334
cls = codec_registry.get(codec_id, None)
3435
if cls is None:

numcodecs/tests/test_registry.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@
1111
def test_registry_errors():
1212
with pytest.raises(ValueError):
1313
get_codec({'id': 'foo'})
14+
15+
16+
def test_get_codec_argument():
17+
# Check that get_codec doesn't modify its argument.
18+
arg = {"id": "json"}
19+
before = dict(arg)
20+
get_codec(arg)
21+
assert before == arg

0 commit comments

Comments
 (0)