diff Objects/memoryobject.c @ 85939:b08e092df155 3.3

Issue #19014: memoryview.cast() is now allowed on zero-length views.
author Antoine Pitrou <solipsis@pitrou.net>
date Thu, 03 Oct 2013 19:55:41 +0200
parents 8c4aa4cb7930
children 1e13a58c1b92
line wrap: on
line diff
--- a/Objects/memoryobject.c	Thu Oct 03 12:08:38 2013 +0300
+++ b/Objects/memoryobject.c	Thu Oct 03 19:55:41 2013 +0200
@@ -1330,7 +1330,7 @@
             "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;