summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2020-05-22 10:05:43 -0500
committerSebastian Berg <sebastian@sipsolutions.net>2020-05-22 10:06:52 -0500
commit1e7ef595cf6ec20c321a93387916f05309f3b4fa (patch)
tree7f756d2eaeda80c5647509adad0b88706de5861c /numpy/lib/tests
parentfc2518ba6b11fc52b0ff477b9e83576be90562d8 (diff)
downloadnumpy-1e7ef595cf6ec20c321a93387916f05309f3b4fa.tar.gz
BUG: Fix dtype leak in `PyArray_FromAny` error path
Also adds a test to bincount which will run into this path. The leak can be triggered by using a reference count checker on the test suit (e.g. pytest-leaks). Closes gh-16339
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r--numpy/lib/tests/test_function_base.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 008ea0759..9ba0be56a 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -2423,6 +2423,15 @@ class TestBincount:
assert_equal(sys.getrefcount(np.dtype(np.intp)), intp_refcount)
assert_equal(sys.getrefcount(np.dtype(np.double)), double_refcount)
+ @pytest.mark.parametrize("vals", [[[2, 2]], 2])
+ def test_error_not_1d(self, vals):
+ # Test that values has to be 1-D (both as array and nested list)
+ vals_arr = np.asarray(vals)
+ with assert_raises(ValueError):
+ np.bincount(vals_arr)
+ with assert_raises(ValueError):
+ np.bincount(vals)
+
class TestInterp: