# Buggy code
def encode_fill_value(v, dtype):
    # early out
    if v is None:
        return v
    if dtype.kind == "f":
        if np.isnan(v):
            return "NaN"
        elif np.isposinf(v):
            return "Infinity"
        elif np.isneginf(v):
            return "-Infinity"
        else:
            return float(v)
    elif dtype.kind in "ui":
        return int(v)
    elif dtype.kind == "b":
        return bool(v)
    elif dtype.kind in "SV":
        v = base64.standard_b64encode(v)
        if not PY2:  # pragma: py2 no cover
            v = str(v, "ascii")
        return v
    elif dtype.kind == "U":
        return v
    elif dtype.kind in "mM":
        return int(v.view("u8"))
    else:
        return v


# Traceback (SystemError)
OverflowError: int too big to convert
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/tom/anaconda3/lib/python3.6/site-packages/zarr/meta.py", line 38, in decode_array_metadata
fill_value = decode_fill_value(meta['fill_value'], dtype)
File "/home/tom/anaconda3/lib/python3.6/site-packages/zarr/meta.py", line 159, in decode_fill_value
return np.array(v, dtype=dtype)[()]
SystemError: <built-in function array> returned a result with an error set
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/tom/anaconda3/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2963, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-156-d1f331fc15fd>", line 6, in <module>
shape=10)
File "/home/tom/anaconda3/lib/python3.6/site-packages/zarr/creation.py", line 274, in full
return create(shape=shape, fill_value=fill_value, **kwargs)
File "/home/tom/anaconda3/lib/python3.6/site-packages/zarr/creation.py", line 123, in create
cache_metadata=cache_metadata, cache_attrs=cache_attrs, read_only=read_only)
File "/home/tom/anaconda3/lib/python3.6/site-packages/zarr/core.py", line 123, in __init__
self._load_metadata()
File "/home/tom/anaconda3/lib/python3.6/site-packages/zarr/core.py", line 140, in _load_metadata
self._load_metadata_nosync()
File "/home/tom/anaconda3/lib/python3.6/site-packages/zarr/core.py", line 155, in _load_metadata_nosync
meta = decode_array_metadata(meta_bytes)
File "/home/tom/anaconda3/lib/python3.6/site-packages/zarr/meta.py", line 50, in decode_array_metadata
raise MetadataError('error decoding metadata: %s' % e)
zarr.errors.MetadataError: error decoding metadata: <built-in function array> returned a result with an error set

# Fixed code
def encode_fill_value(v, dtype):
    # early out
    if v is None:
        return v
    if dtype.kind == "f":
        if np.isnan(v):
            return "NaN"
        elif np.isposinf(v):
            return "Infinity"
        elif np.isneginf(v):
            return "-Infinity"
        else:
            return float(v)
    elif dtype.kind in "ui":
        return int(v)
    elif dtype.kind == "b":
        return bool(v)
    elif dtype.kind in "SV":
        v = base64.standard_b64encode(v)
        if not PY2:  # pragma: py2 no cover
            v = str(v, "ascii")
        return v
    elif dtype.kind == "U":
        return v
    elif dtype.kind in "mM":
        return int(v.view("i8"))
    else:
        return v