lebedov / msgpack-numpy

Serialize numpy arrays using msgpack
Other
194 stars 33 forks source link

0.4.4 failed with Python 2 #32

Closed ppwwyyxx closed 5 years ago

ppwwyyxx commented 5 years ago
import numpy as np
import msgpack
import msgpack_numpy
msgpack_numpy.patch()
msgpack_numpy.dumps(np.random.rand(3,3))

Failed when run with python 2 with:

msgpack==0.5.6
msgpack-numpy==0.4.4

and the error message:

Traceback (most recent call last):
  File "bug.py", line 8, in <module>
    msgpack_numpy.dumps(np.random.rand(3,3))
  File "/HOME/.local/lib/python2.7/site-packages/msgpack_numpy.py", line 165, in packb
    return Packer(**kwargs).pack(o)
  File "msgpack/_packer.pyx", line 284, in msgpack._packer.Packer.pack
  File "msgpack/_packer.pyx", line 290, in msgpack._packer.Packer.pack
  File "msgpack/_packer.pyx", line 287, in msgpack._packer.Packer.pack
  File "msgpack/_packer.pyx", line 234, in msgpack._packer.Packer._pack
  File "msgpack/_packer.pyx", line 281, in msgpack._packer.Packer._pack
TypeError: can't serialize <read-write buffer for 0x7f08bfd28120, size 72, offset 0 at 0x7f08bfd15bf0> 
lebedov commented 5 years ago

Fixed.