Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: converting list of ctypes.Structure to ndarray #13628

Open
mattip opened this issue May 26, 2019 · 1 comment
Open

BUG: converting list of ctypes.Structure to ndarray #13628

mattip opened this issue May 26, 2019 · 1 comment

Comments

@mattip
Copy link
Member

mattip commented May 26, 2019

Split out of #13399

class Struct(ctypes.Structure):
    _fields_ = [('a', ctypes.c_uint8), ('b', ctypes.c_uint16)]

data = (Struct * 4)()
np.array(data)  # ok
np.array(list(data))
# RuntimeWarning: A builtin ctypes object gave a PEP3118 format string that does not match its itemsize, so a best-guess will be made of the data type. Newer versions of python may behave correctly.
# ValueError: invalid literal for int() with base 10: b'\x00\x00\x00\x00'

We should either correctly parse an iterable of buffers or raise a better error.

@eric-wieser
Copy link
Member

For anyone trying to implement this - note that that example is maliciously constructed to run afoul of python/cpython#5561.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants