[pypy-issue] Issue #2930: memoryview(ctypes.Structure) does not produce the correct format string (pypy/pypy)

mattip issues-reply at bitbucket.org
Tue Dec 11 06:46:07 EST 2018


New issue 2930: memoryview(ctypes.Structure) does not produce the correct format string
https://bitbucket.org/pypy/pypy/issues/2930/memoryview-ctypesstructure-does-not

mattip:

The following passes on CPython, fails on PyPy (`mv.format` is `B`)

```
class Struct(Structure):
    _fields_ = [('a', c_int16)]

Struct3 = 3 * Struct

c_array = (2 * Struct3)(
    Struct3(Struct(a=1), Struct(a=2), Struct(a=3)),
    Struct3(Struct(a=4), Struct(a=5), Struct(a=6))
)

mv = memoryview(c_array)
assert mv.format == 'T{<h:a:}'
```
The `memoryview` call goes to `_CData.__buffer__` in `lib_pypy._ctypes.basics.py`, which should not just call `buffer(self._buffer)`




More information about the pypy-issue mailing list