diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2018-05-27 14:45:30 +0800 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2018-05-31 12:56:28 +0800 |
commit | 8374023e3ae0ad4c9ceffb8b5c29aa1fde20433f (patch) | |
tree | 3e1bd54f29edc7b34bc59b2caab0fa46a153f64e /astroid/protocols.py | |
parent | 329deed20f8f8d65288ff7ae01b12e69c66f08c7 (diff) | |
download | astroid-git-8374023e3ae0ad4c9ceffb8b5c29aa1fde20433f.tar.gz |
Remove reraise() in favour of using raise..from
Diffstat (limited to 'astroid/protocols.py')
-rw-r--r-- | astroid/protocols.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/astroid/protocols.py b/astroid/protocols.py index 641605c5..4ff46fbb 100644 --- a/astroid/protocols.py +++ b/astroid/protocols.py @@ -271,10 +271,10 @@ def sequence_assigned_stmts(self, node=None, context=None, asspath=None): asspath = [] try: index = self.elts.index(node) - except ValueError: - util.reraise(exceptions.InferenceError( + except ValueError as exc: + raise exceptions.InferenceError( 'Tried to retrieve a node {node!r} which does not exist', - node=self, assign_path=asspath, context=context)) + node=self, assign_path=asspath, context=context) from exc asspath.insert(0, index) return self.parent.assigned_stmts(node=self, context=context, asspath=asspath) @@ -519,16 +519,16 @@ def with_assigned_stmts(self, node=None, context=None, asspath=None): context=context) try: obj = obj.elts[index] - except IndexError: - util.reraise(exceptions.InferenceError( + except IndexError as exc: + raise exceptions.InferenceError( 'Tried to infer a nonexistent target with index {index} ' 'in {node!r}.', node=self, targets=node, - assign_path=asspath, context=context)) - except TypeError: - util.reraise(exceptions.InferenceError( + assign_path=asspath, context=context) from exc + except TypeError as exc: + raise exceptions.InferenceError( 'Tried to unpack an non-iterable value ' 'in {node!r}.', node=self, targets=node, - assign_path=asspath, context=context)) + assign_path=asspath, context=context) from exc yield obj # Explicit StopIteration to return error information, see comment # in raise_if_nothing_inferred. |