diff options
| author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-07-19 21:23:24 +0200 |
|---|---|---|
| committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-07-19 23:32:34 +0200 |
| commit | 1e32ea4dc5c54bd644f36b239e022f8c2787eba2 (patch) | |
| tree | c575e3ec45cca4200a68065bbdee3581dab1f18d | |
| parent | 2738e93afed92ad7b495dbc3036c675a8701c2c6 (diff) | |
| download | astroid-git-1e32ea4dc5c54bd644f36b239e022f8c2787eba2.tar.gz | |
Catch StopIteration and reraise cleanly
Closes https://github.com/PyCQA/pylint/issues/4723
| -rw-r--r-- | astroid/protocols.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/astroid/protocols.py b/astroid/protocols.py index 5ef9630b..cb2dbaf1 100644 --- a/astroid/protocols.py +++ b/astroid/protocols.py @@ -490,8 +490,10 @@ def _infer_context_manager(self, mgr, context): else: # It doesn't interest us. raise InferenceError(node=func) - - yield next(inferred.infer_yield_types()) + try: + yield next(inferred.infer_yield_types()) + except StopIteration as e: + raise InferenceError(node=func) from e elif isinstance(inferred, bases.Instance): try: |
