diff options
author | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-05-09 21:08:46 +0300 |
---|---|---|
committer | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-05-09 21:08:46 +0300 |
commit | c8cf9abf3254915a65c352981a604bcfb3005d49 (patch) | |
tree | 95282554b131971953f06a61accc4a601b7bfd47 /astroid/protocols.py | |
parent | f889db0320246e52a9b6ff7f75a33c333d53b2de (diff) | |
download | astroid-c8cf9abf3254915a65c352981a604bcfb3005d49.tar.gz |
Raise an InferenceError when having multiple 'as' bindings from a context manager, but the result doesn't have those indices.
Diffstat (limited to 'astroid/protocols.py')
-rw-r--r-- | astroid/protocols.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/astroid/protocols.py b/astroid/protocols.py index 5e7650a..fc7f10d 100644 --- a/astroid/protocols.py +++ b/astroid/protocols.py @@ -427,7 +427,10 @@ def with_assigned_stmts(self, node, context=None, asspath=None): for index in asspath: if not hasattr(obj, 'elts'): raise InferenceError - obj = obj.elts[index] + try: + obj = obj.elts[index] + except IndexError: + raise InferenceError yield obj |