Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Release notes
-----

* Handle (new) buffer protocol conforming types in ``Pickle.decode``.
By :user:`John Kirkham <jakirkham>`, :issue:`143`.
By :user:`John Kirkham <jakirkham>`, :issue:`143`, :issue:`150`.

* Fix other ``VLen*`` encode() methods to return numpy arrays as well.
By :user:`John Kirkham <jakirkham>`, :issue:`144`.
Expand Down
10 changes: 6 additions & 4 deletions numcodecs/pickles.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@


from .abc import Codec
from .compat import PY2, ensure_bytes, ensure_contiguous_ndarray
from .compat import PY2, ensure_contiguous_ndarray


if PY2: # pragma: py3 no cover
import cPickle as pickle
from cStringIO import StringIO
else: # pragma: py2 no cover
import pickle

Expand Down Expand Up @@ -48,12 +49,13 @@ def encode(self, buf):
return pickle.dumps(buf, protocol=self.protocol)

def decode(self, buf, out=None):
buf = ensure_contiguous_ndarray(buf)

if PY2: # pragma: py3 no cover
buf = ensure_bytes(buf)
dec = pickle.load(StringIO(buf))
else: # pragma: py2 no cover
buf = ensure_contiguous_ndarray(buf)
dec = pickle.loads(buf)

dec = pickle.loads(buf)
if out is not None:
np.copyto(out, dec)
return out
Expand Down