diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-06-22 08:21:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-22 08:21:04 (GMT) |
commit | b99824a8e14d94c3c5c29499a08fe70deb477d0c (patch) | |
tree | 2071b90c828dccc80d65b6b280197d97b9162c9f /Objects | |
parent | d5ee9b9940ba24120838b07061058afe931cfff1 (diff) | |
download | cpython-b99824a8e14d94c3c5c29499a08fe70deb477d0c.zip cpython-b99824a8e14d94c3c5c29499a08fe70deb477d0c.tar.gz cpython-b99824a8e14d94c3c5c29499a08fe70deb477d0c.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().
(cherry picked from commit cafe1b6e9d3594a34aba50e872d4198296ffaadf)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/abstract.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index 4fabfd7..12237d5 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -1999,7 +1999,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; } |