Author: mattip <[email protected]>
Branch: 
Changeset: r78954:7860229d39ac
Date: 2015-08-12 23:54 +0300
http://bitbucket.org/pypy/pypy/changeset/7860229d39ac/

Log:    test, fix unpickling 'V0' (builtin, empty) subarray in record dtype

diff --git a/pypy/module/micronumpy/descriptor.py 
b/pypy/module/micronumpy/descriptor.py
--- a/pypy/module/micronumpy/descriptor.py
+++ b/pypy/module/micronumpy/descriptor.py
@@ -588,7 +588,8 @@
         return space.newtuple([w_class, builder_args, data])
 
     def descr_setstate(self, space, w_data):
-        if self.fields is None:  # if builtin dtype
+        if self.fields is None and not isinstance(self.itemtype, 
types.VoidType):  
+            # if builtin dtype (but not w_voiddtype)
             return space.w_None
 
         version = space.int_w(space.getitem(w_data, space.wrap(0)))
diff --git a/pypy/module/micronumpy/test/test_ndarray.py 
b/pypy/module/micronumpy/test/test_ndarray.py
--- a/pypy/module/micronumpy/test/test_ndarray.py
+++ b/pypy/module/micronumpy/test/test_ndarray.py
@@ -3808,7 +3808,7 @@
         assert (a == [1, 2]).all()
 
     def test_pickle(self):
-        from numpy import dtype, array
+        from numpy import dtype, array, int32
         from cPickle import loads, dumps
 
         d = dtype([('x', str), ('y', 'int32')])
@@ -3825,6 +3825,11 @@
 
         assert a[0]['y'] == 2
         assert a[1]['y'] == 1
+        
+        a = array([(1, [])], dtype=[('a', int32), ('b', int32, 0)])
+        assert a['b'].shape == (1, 0)
+        b = loads(dumps(a))
+        assert b['b'].shape == (1, 0)
 
     def test_subarrays(self):
         from numpy import dtype, array, zeros
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to