summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/src/umath/scalarmath.c.src6
1 files changed, 5 insertions, 1 deletions
diff --git a/numpy/core/src/umath/scalarmath.c.src b/numpy/core/src/umath/scalarmath.c.src
index 3b23151f1..7b424cc74 100644
--- a/numpy/core/src/umath/scalarmath.c.src
+++ b/numpy/core/src/umath/scalarmath.c.src
@@ -1424,7 +1424,11 @@ static PyObject *
#ifndef NPY_PY3K
/* Invoke long.__int__ to try to downcast */
- long_result = Py_TYPE(long_result)->tp_as_number->nb_int(long_result);
+ {
+ PyObject *before_downcast = long_result;
+ long_result = Py_TYPE(long_result)->tp_as_number->nb_int(long_result);
+ Py_DECREF(before_downcast);
+ }
#endif
return long_result;