diff options
Diffstat (limited to 'numpy/lib')
-rw-r--r-- | numpy/lib/src/_compiled_base.c | 4 | ||||
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/numpy/lib/src/_compiled_base.c b/numpy/lib/src/_compiled_base.c index 99aec38f0..9d9344526 100644 --- a/numpy/lib/src/_compiled_base.c +++ b/numpy/lib/src/_compiled_base.c @@ -295,8 +295,8 @@ arr_digitize(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds) } fail: - Py_DECREF(arr_x); - Py_DECREF(arr_bins); + Py_XDECREF(arr_x); + Py_XDECREF(arr_bins); return ret; } diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 80faf85a6..03521ca4c 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -861,6 +861,13 @@ class TestDigitize(TestCase): bins = [1, 1, 0, 1] assert_raises(ValueError, digitize, x, bins) + def test_casting_error(self): + x = [1, 2, 3+1.j] + bins = [1, 2, 3] + assert_raises(TypeError, digitize, x, bins) + x, bins = bins, x + assert_raises(TypeError, digitize, x, bins) + class TestUnwrap(TestCase): def test_simple(self): |