__Pyx_BufferNdimError(buf, nd);
goto fail;
}
+ if (buf->itemsize != sizeof(%(dtype_cname)s)) {
+ PyErr_SetString(PyExc_ValueError,
+ "Item size of buffer does not match size of %(dtype)s.");
+ goto fail;
+ }
if (!cast) {
ts = buf->format;
ts = __Pyx_ConsumeWhitespace(ts);
__Pyx_DescribeTokenInFormatString(ts));
goto fail;
}
- } else {
- if (buf->itemsize != sizeof(%(dtype_cname)s)) {
- PyErr_SetString(PyExc_ValueError,
- "Attempted cast of buffer to datatype of different size.");
- goto fail;
- }
}
if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
return 0;