summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/umath/loops.c.src6
1 files changed, 5 insertions, 1 deletions
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src
index 32aac3ff7..8a2e5bc40 100644
--- a/numpy/core/src/umath/loops.c.src
+++ b/numpy/core/src/umath/loops.c.src
@@ -235,7 +235,11 @@ PyUFunc_O_O_method(char **args, npy_intp *dimensions, npy_intp *steps, void *fun
PyObject **out = (PyObject **)op1;
PyObject *ret, *func;
func = PyObject_GetAttrString(in1 ? in1 : Py_None, meth);
- if (func == NULL || !PyCallable_Check(func)) {
+ if (func != NULL && !PyCallable_Check(func)) {
+ Py_DECREF(func);
+ func = NULL;
+ }
+ if (func == NULL) {
PyObject *exc, *val, *tb;
PyTypeObject *type = in1 ? Py_TYPE(in1) : Py_TYPE(Py_None);
PyErr_Fetch(&exc, &val, &tb);