summaryrefslogtreecommitdiff
path: root/astroid/protocols.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2019-01-18 18:54:30 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2019-01-18 18:54:30 +0100
commit02699bad102678273dcd6bbeb7d3f6100f4547fb (patch)
treeb973f9b8b9065f0835bd4bfb0f8addf14f7e9ab1 /astroid/protocols.py
parent0e1ab4ac02b1946851496585459930f0d7b6f03e (diff)
downloadastroid-git-02699bad102678273dcd6bbeb7d3f6100f4547fb.tar.gz
Remove StopIteration handling which should not leak at all from inference
Diffstat (limited to 'astroid/protocols.py')
-rw-r--r--astroid/protocols.py13
1 files changed, 3 insertions, 10 deletions
diff --git a/astroid/protocols.py b/astroid/protocols.py
index 86889b43..f3032caf 100644
--- a/astroid/protocols.py
+++ b/astroid/protocols.py
@@ -455,7 +455,7 @@ nodes.ExceptHandler.assigned_stmts = excepthandler_assigned_stmts
def _infer_context_manager(self, mgr, context):
try:
inferred = next(mgr.infer(context=context))
- except (StopIteration, exceptions.InferenceError):
+ except exceptions.InferenceError:
return
if isinstance(inferred, bases.Generator):
# Check if it is decorated with contextlib.contextmanager.
@@ -463,10 +463,7 @@ def _infer_context_manager(self, mgr, context):
if not func.decorators:
return
for decorator_node in func.decorators.nodes:
- try:
- decorator = next(decorator_node.infer(context))
- except StopIteration:
- return
+ decorator = next(decorator_node.infer(context))
if isinstance(decorator, nodes.FunctionDef):
if decorator.qname() == _CONTEXTLIB_MGR:
break
@@ -493,11 +490,7 @@ def _infer_context_manager(self, mgr, context):
elif isinstance(inferred, bases.Instance):
try:
enter = next(inferred.igetattr("__enter__", context=context))
- except (
- StopIteration,
- exceptions.InferenceError,
- exceptions.AttributeInferenceError,
- ):
+ except (exceptions.InferenceError, exceptions.AttributeInferenceError):
return
if not isinstance(enter, bases.BoundMethod):
return