summaryrefslogtreecommitdiffstats
path: root/Objects/abstract.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-06-22 07:43:35 (GMT)
committerGitHub <noreply@github.com>2020-06-22 07:43:35 (GMT)
commitcafe1b6e9d3594a34aba50e872d4198296ffaadf (patch)
tree4508274bc56f2a9fe7caef1f61dbdae524a157be /Objects/abstract.c
parent4901ea952691ad70aae21cfe04b6bd363b5a6aff (diff)
downloadcpython-cafe1b6e9d3594a34aba50e872d4198296ffaadf.zip
cpython-cafe1b6e9d3594a34aba50e872d4198296ffaadf.tar.gz
cpython-cafe1b6e9d3594a34aba50e872d4198296ffaadf.tar.bz2
bpo-40824: Do not mask errors in __iter__ in "in" and the operator module. (GH-20537)
Unexpected errors in calling the __iter__ method are no longer masked by TypeError in the "in" operator and functions operator.contains(), operator.indexOf() and operator.countOf().
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r--Objects/abstract.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 973c43f..aac42c2 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2083,7 +2083,9 @@ _PySequence_IterSearch(PyObject *seq, PyObject *obj, int operation)
it = PyObject_GetIter(seq);
if (it == NULL) {
- type_error("argument of type '%.200s' is not iterable", seq);
+ if (PyErr_ExceptionMatches(PyExc_TypeError)) {
+ type_error("argument of type '%.200s' is not iterable", seq);
+ }
return -1;
}