summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2018-05-30 23:20:25 -0700
committerGitHub <noreply@github.com>2018-05-30 23:20:25 -0700
commit9939691b86be9eb144622afc6b2796b659ce38bc (patch)
treee30183fe8e0825e12088063c6b0cb77365dc630b /numpy/core
parenta2ff5aa5268b72986f3e84836b52822c209d088d (diff)
parentecc63ca5849f617ffd2ab7420b5d749a752ab5ec (diff)
downloadnumpy-9939691b86be9eb144622afc6b2796b659ce38bc.tar.gz
Merge pull request #11193 from mhvk/gufunc-sig-signature-override-bug
BUG: reference count/memory leak exposed by better testing
Diffstat (limited to 'numpy/core')
-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')