summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2018-08-03 09:48:37 -0600
committerCharles Harris <charlesr.harris@gmail.com>2018-08-06 14:18:51 -0600
commitec1e79f8a1de1e75d537da7444a230592a1c9e3b (patch)
tree3af2e5c92f0c34b6cbe76f75847fcd9fcfe9bcff /numpy
parent8eed36af75d0cc002b3e839e828d8892c1f079d5 (diff)
downloadnumpy-ec1e79f8a1de1e75d537da7444a230592a1c9e3b.tar.gz
BUG: Fix regression in void_getitem
The return value for a void array was not correct. Closes #11668.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/arraytypes.c.src2
-rw-r--r--numpy/core/tests/test_regression.py7
2 files changed, 8 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/arraytypes.c.src b/numpy/core/src/multiarray/arraytypes.c.src
index b4158ec8e..d622effe6 100644
--- a/numpy/core/src/multiarray/arraytypes.c.src
+++ b/numpy/core/src/multiarray/arraytypes.c.src
@@ -733,7 +733,7 @@ VOID_getitem(void *input, void *vap)
return (PyObject *)ret;
}
- return PyBytes_FromStringAndSize(PyArray_DATA(ap), descr->elsize);
+ return PyBytes_FromStringAndSize(ip, descr->elsize);
}
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index 5f4410d54..36478ddb7 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -2368,6 +2368,13 @@ class TestRegression(object):
del va
assert_equal(x, b'\x00\x00\x00\x00')
+ def test_void_getitem(self):
+ # Test fix for gh-11668.
+ assert_(np.array([b'a'], 'V1').astype('O') == b'a')
+ assert_(np.array([b'ab'], 'V2').astype('O') == b'ab')
+ assert_(np.array([b'abc'], 'V3').astype('O') == b'abc')
+ assert_(np.array([b'abcd'], 'V4').astype('O') == b'abcd')
+
def test_structarray_title(self):
# The following used to segfault on pypy, due to NPY_TITLE_KEY
# not working properly and resulting to double-decref of the