Commits

Romain Guillebert  committed 9e583c8

Fix PyPy issue 1589

  • Participants
  • Parent commits 2cb50d5

Comments (0)

Files changed (2)

File pypy/module/micronumpy/test/test_numarray.py

 
         assert len(list(a[0])) == 2
 
+    def test_issue_1589(self):
+        import numpypy as numpy
+        c = numpy.array([[(1, 2, 'a'), (3, 4, 'b')], [(5, 6, 'c'), (7, 8, 'd')]],
+                        dtype=[('bg', 'i8'), ('fg', 'i8'), ('char', 'S1')])
+        assert c[0][0]["char"] == 'a'
+
 class AppTestPyPy(BaseNumpyAppTest):
     def setup_class(cls):
         if option.runappdirect and '__pypy__' not in sys.builtin_module_names:

File pypy/module/micronumpy/types.py

 
     def store(self, arr, i, offset, box):
         assert isinstance(box, interp_boxes.W_StringBox)
-        # XXX simplify to range(box.dtype.get_size()) ?
         return self._store(arr.storage, i, offset, box)
 
     @jit.unroll_safe
     def _store(self, storage, i, offset, box):
         assert isinstance(box, interp_boxes.W_StringBox)
-        for k in range(min(self.size, box.arr.size-offset)):
-            storage[k + i] = box.arr.storage[k + offset]
+        # XXX simplify to range(box.dtype.get_size()) ?
+        for k in range(min(self.size, box.arr.size-box.ofs)):
+            storage[k + offset + i] = box.arr.storage[k + box.ofs]
 
     def read(self, arr, i, offset, dtype=None):
         if dtype is None: