New issue 2874: numpy.frombuffer(ffi.buffer(x)) fails with the official numpy 
module.
https://bitbucket.org/pypy/pypy/issues/2874/numpyfrombuffer-ffibuffer-x-fails-with-the

HexDecimal:

This is valid CPython code, it also works on PyPy with the pypy/numpy fork:
```python
import cffi, numpy
ffi = cffi.FFI()
c_array = ffi.new('int[4]')
buf = ffi.buffer(c_array)
np_array = numpy.frombuffer(buf, numpy.intc)
print(np_array)
```
But when run on PyPy with the official numpy module you'll get this error:
```
Traceback (most recent call last):
  File "test.py", line 5, in <module>
    np_array = numpy.frombuffer(buf, numpy.intc)
AttributeError: '_cffi_backend.buffer' object has no attribute '__buffer__'
```
I can work around the error on PyPy3 by wrapping `buf` in a `memoryview` but 
that breaks Python2.


_______________________________________________
pypy-issue mailing list
pypy-issue@python.org
https://mail.python.org/mailman/listinfo/pypy-issue

Reply via email to