[pypy-commit] pypy py3.5: Since 3.3, 0-D memoryviews return an empty tuple for .shape and .strides (hard to test at app-level)

rlamy pypy.commits at gmail.com
Sat Feb 11 14:17:34 EST 2017


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.5
Changeset: r90057:e06ef56cac01
Date: 2017-02-11 19:16 +0000
http://bitbucket.org/pypy/pypy/changeset/e06ef56cac01/

Log:	Since 3.3, 0-D memoryviews return an empty tuple for .shape and
	.strides (hard to test at app-level)

diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py
--- a/pypy/module/cpyext/slotdefs.py
+++ b/pypy/module/cpyext/slotdefs.py
@@ -323,11 +323,11 @@
         self.w_obj = w_obj # kept alive
         self.pyobj = make_ref(space, w_obj)
         self.format = format
-        if not shape:
+        if shape is None:
             self.shape = [size]
         else:
             self.shape = shape
-        if not strides:
+        if strides is None:
             self.strides = [1]
         else:
             self.strides = strides
diff --git a/pypy/objspace/std/memoryobject.py b/pypy/objspace/std/memoryobject.py
--- a/pypy/objspace/std/memoryobject.py
+++ b/pypy/objspace/std/memoryobject.py
@@ -428,14 +428,10 @@
 
     def w_get_shape(self, space):
         self._check_released(space)
-        if self.getndim() == 0:
-            return space.w_None
         return space.newtuple([space.wrap(x) for x in self.getshape()])
 
     def w_get_strides(self, space):
         self._check_released(space)
-        if self.getndim() == 0:
-            return space.w_None
         return space.newtuple([space.wrap(x) for x in self.getstrides()])
 
     def w_get_suboffsets(self, space):


More information about the pypy-commit mailing list