summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2018-08-06 21:42:45 -0700
committerGitHub <noreply@github.com>2018-08-06 21:42:45 -0700
commitba15a4c56597bc2284059e5c6750aaaa03e7a411 (patch)
treea49a8f7d0e9370e7694968f4a355a9bcd1050a7e /numpy/core
parent5b0932117d96425677a4143d2cf3c7af6f4d92ad (diff)
parentec1e79f8a1de1e75d537da7444a230592a1c9e3b (diff)
downloadnumpy-ba15a4c56597bc2284059e5c6750aaaa03e7a411.tar.gz
Merge pull request #11669 from charris/fix-void_getitem-regression
BUG: Fix regression in `void_getitem`
Diffstat (limited to 'numpy/core')
-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