summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattip <matti.picus@gmail.com>2018-07-05 21:52:30 -0700
committermattip <matti.picus@gmail.com>2018-07-05 21:52:30 -0700
commiteda0b3a475ef7bb5c1976e56184cc4810fa5024c (patch)
tree2e830f94324be1c29bcda51613fb47457c8ade79
parent739443679b50b43c34808b8fb767bac643fcd91d (diff)
downloadnumpy-eda0b3a475ef7bb5c1976e56184cc4810fa5024c.tar.gz
BUG: decref of field title caused segfault
-rw-r--r--numpy/core/src/multiarray/mapping.c1
-rw-r--r--numpy/core/tests/test_regression.py12
2 files changed, 12 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/mapping.c b/numpy/core/src/multiarray/mapping.c
index cdca1d606..49ca14a14 100644
--- a/numpy/core/src/multiarray/mapping.c
+++ b/numpy/core/src/multiarray/mapping.c
@@ -1546,7 +1546,6 @@ _get_field_view(PyArrayObject *arr, PyObject *ind, PyArrayObject **view,
Py_DECREF(names);
return 0;
}
- Py_DECREF(title);
}
/* disallow duplicate field indices */
if (PyDict_Contains(fields, name)) {
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index ba4413138..62f592524 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -2391,3 +2391,15 @@ class TestRegression(object):
squeezed = scvalue.squeeze(axis=axis)
assert_equal(squeezed, scvalue)
assert_equal(type(squeezed), type(scvalue))
+
+ def test_field_access_by_title(self):
+ # gh-11507
+ s = 'Some long field name'
+ if HAS_REFCOUNT:
+ base = sys.getrefcount(s)
+ t = np.dtype([((s, 'f1'), np.float64)])
+ data = np.zeros(10, t)
+ for i in range(10):
+ v = str(data[['f1']])
+ if HAS_REFCOUNT:
+ assert_(base <= sys.getrefcount(s))