Why does creating this memoryview raise a ValueError only when assigning to a variable? Why does creating this memoryview raise a ValueError only when assigning to a variable? python python

Why does creating this memoryview raise a ValueError only when assigning to a variable?


There is something very odd going on here.

>>> memoryview(zeros(10, dtype=[("A", "m8[s]")]))<memory at 0x102654348>>>> ValueError: cannot include dtype 'm' in a buffer

My conjecture is that this is related to https://bugs.python.org/issue23571. Some C function underlying memoryview is both returning a non-null result and setting an error flag. This apparently causes the error to be raised when the next statement is executed! In Python 3.5, the interpreter raises a SystemError instead when this condition occurs.

It seems like the real bug here is with the memoryview function, not with numpy.