summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorMarten van Kerkwijk <mhvk@astro.utoronto.ca>2018-05-02 11:31:24 -0400
committerMarten van Kerkwijk <mhvk@astro.utoronto.ca>2018-05-30 10:35:49 -0400
commitecc63ca5849f617ffd2ab7420b5d749a752ab5ec (patch)
tree005f27cec2d68a5dd49971d2a4882c4bf040e6c0 /numpy
parent6721890e86291b53fb8dcbee6809891c348ae98e (diff)
downloadnumpy-ecc63ca5849f617ffd2ab7420b5d749a752ab5ec.tar.gz
BUG: reference count exposed by better testing
Also for __array_ufunc__ overrides, sig and signature cannot be passed in both. This was incorrectly coded and slipped through as it was not tested.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/umath/override.c6
-rw-r--r--numpy/core/tests/test_umath.py1
2 files changed, 5 insertions, 2 deletions
diff --git a/numpy/core/src/umath/override.c b/numpy/core/src/umath/override.c
index 123d9af87..c298fe315 100644
--- a/numpy/core/src/umath/override.c
+++ b/numpy/core/src/umath/override.c
@@ -29,7 +29,10 @@ normalize_signature_keyword(PyObject *normal_kwds)
"cannot specify both 'sig' and 'signature'");
return -1;
}
- Py_INCREF(obj);
+ /*
+ * No INCREF or DECREF needed: got a borrowed reference above,
+ * and, unlike e.g. PyList_SetItem, PyDict_SetItem INCREF's it.
+ */
PyDict_SetItemString(normal_kwds, "signature", obj);
PyDict_DelItemString(normal_kwds, "sig");
}
@@ -291,7 +294,6 @@ normalize_outer_args(PyUFuncObject *ufunc, PyObject *args,
if (*normal_args == NULL) {
return -1;
}
-
/* ufuncs accept 'sig' or 'signature' normalize to 'signature' */
return normalize_signature_keyword(*normal_kwds);
}
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index 2a42b1ed1..0d9689bcf 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -1940,6 +1940,7 @@ class TestSpecialMethods(object):
# outer, wrong args
assert_raises(TypeError, np.multiply.outer, a)
assert_raises(TypeError, np.multiply.outer, a, a, a, a)
+ assert_raises(TypeError, np.multiply.outer, a, a, sig='a', signature='a')
# at
res = np.multiply.at(a, [4, 2], 'b0')