Issue #19014: memoryview.cast() is now allowed on zero-length views.

This commit is contained in:
Antoine Pitrou 2013-10-03 19:56:54 +02:00
commit 0e61ed8400
3 changed files with 13 additions and 5 deletions

View file

@ -1330,7 +1330,7 @@ memory_cast(PyMemoryViewObject *self, PyObject *args, PyObject *kwds)
"memoryview: casts are restricted to C-contiguous views");
return NULL;
}
if (zero_in_shape(self)) {
if ((shape || self->view.ndim != 1) && zero_in_shape(self)) {
PyErr_SetString(PyExc_TypeError,
"memoryview: cannot cast view with zeros in shape or strides");
return NULL;