Author: mattip <matti.pi...@gmail.com> Branch: Changeset: r79957:a3564b6798cb Date: 2015-10-04 00:25 +0300 http://bitbucket.org/pypy/pypy/changeset/a3564b6798cb/
Log: test, fix for overrun end of storage when offset, i non-zero 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 @@ -2475,6 +2475,18 @@ a.fill(12) assert (a == u'1').all() + def test_unicode_record_array(self) : + from numpy import dtype, array + t = dtype([('a', 'S3'), ('b', 'U2')]) + x = array([('a', u'b')], dtype=t) + assert str(x) == "[('a', u'b')]" + + t = dtype([('a', 'U3'), ('b', 'S2')]) + x = array([(u'a', 'b')], dtype=t) + x['a'] = u'1' + assert str(x) == "[(u'1', 'b')]" + + def test_boolean_indexing(self): import numpy as np a = np.zeros((1, 3)) diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py --- a/pypy/module/micronumpy/types.py +++ b/pypy/module/micronumpy/types.py @@ -2231,9 +2231,9 @@ index = i + offset + 4*k data = rffi.cast(Int32.T, ord(box._value[k])) raw_storage_setitem_unaligned(storage, index, data) - for k in range(size, width // 4): - index = i + offset + 4*k - data = rffi.cast(Int32.T, 0) + # zero out the remaining memory + for index in range(size * 4 + i + offset, width): + data = rffi.cast(Int8.T, 0) raw_storage_setitem_unaligned(storage, index, data) def read(self, arr, i, offset, dtype): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit