diff --git a/zarr/storage.py b/zarr/storage.py index d71ee3a18a..656b05acf8 100644 --- a/zarr/storage.py +++ b/zarr/storage.py @@ -2147,7 +2147,15 @@ def __getitem__(self, key): if doc is None: raise KeyError(key) else: - return binary_type(doc[self._value]) + value = doc[self._value] + + # Coerce `bson.Binary` to `bytes` type on Python 2. + # PyMongo handles this conversion for us on Python 3. + # ref: http://api.mongodb.com/python/current/python3.html#id3 + if PY2: # pragma: py3 no cover + value = binary_type(value) + + return value def __setitem__(self, key, value): value = ensure_bytes(value)