summaryrefslogtreecommitdiff
path: root/numpy/core/src
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2021-01-20 17:57:37 -0700
committerGitHub <noreply@github.com>2021-01-20 17:57:37 -0700
commit72be9ca10b5391fc036c4cd61830e168712b51ea (patch)
tree6d3bf30490c291982a2eabeabb487fbdfd7e0335 /numpy/core/src
parentf10da39336097fca740dd1c407939eb9c6c4ca3e (diff)
parenta054ffd20ba2cd865a53e6ab149ae7d24acc97d9 (diff)
downloadnumpy-72be9ca10b5391fc036c4cd61830e168712b51ea.tar.gz
Merge pull request #18197 from seberg/array-protocol-errors
BUG: Keep ignoring most errors during array-protocol lookup
Diffstat (limited to 'numpy/core/src')
-rw-r--r--numpy/core/src/multiarray/ctors.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c
index 58571b678..ef105ff2d 100644
--- a/numpy/core/src/multiarray/ctors.c
+++ b/numpy/core/src/multiarray/ctors.c
@@ -2124,7 +2124,16 @@ PyArray_FromInterface(PyObject *origin)
if (iface == NULL) {
if (PyErr_Occurred()) {
- return NULL;
+ if (PyErr_ExceptionMatches(PyExc_RecursionError) ||
+ PyErr_ExceptionMatches(PyExc_MemoryError)) {
+ /* RecursionError and MemoryError are considered fatal */
+ return NULL;
+ }
+ /*
+ * This probably be deprecated, but at least shapely raised
+ * a NotImplementedError expecting it to be cleared (gh-17965)
+ */
+ PyErr_Clear();
}
return Py_NotImplemented;
}
@@ -2392,7 +2401,13 @@ PyArray_FromArrayAttr(PyObject *op, PyArray_Descr *typecode, PyObject *context)
array_meth = PyArray_LookupSpecial_OnInstance(op, "__array__");
if (array_meth == NULL) {
if (PyErr_Occurred()) {
- return NULL;
+ if (PyErr_ExceptionMatches(PyExc_RecursionError) ||
+ PyErr_ExceptionMatches(PyExc_MemoryError)) {
+ /* RecursionError and MemoryError are considered fatal */
+ return NULL;
+ }
+ /* This probably be deprecated. */
+ PyErr_Clear();
}
return Py_NotImplemented;
}