diff options
author | Ganesh Kathiresan <ganesh3597@gmail.com> | 2020-02-14 03:37:23 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-13 14:07:23 -0800 |
commit | 491f41acd2c6a0e7886662a2448b3d245ae432a9 (patch) | |
tree | 4865c296679b89ee64eb8af29aed4cc23050b60b | |
parent | 74afdda39be21af56b8f9ea9abdb1e8f994e5350 (diff) | |
download | numpy-491f41acd2c6a0e7886662a2448b3d245ae432a9.tar.gz |
BUG: Added missing error check in `ndarray.__contains__` (gh-15553)
Addes missing check for NULL return.
resolves #15552
resolves pandas-dev/pandas#31922
-rw-r--r-- | numpy/core/src/multiarray/sequence.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/numpy/core/src/multiarray/sequence.c b/numpy/core/src/multiarray/sequence.c index 4769bdad9..1efdd204f 100644 --- a/numpy/core/src/multiarray/sequence.c +++ b/numpy/core/src/multiarray/sequence.c @@ -38,8 +38,13 @@ array_contains(PyArrayObject *self, PyObject *el) if (res == NULL) { return -1; } + any = PyArray_Any((PyArrayObject *)res, NPY_MAXDIMS, NULL); Py_DECREF(res); + if (any == NULL) { + return -1; + } + ret = PyObject_IsTrue(any); Py_DECREF(any); return ret; |