diff options
author | Ceridwen <ceridwenv@gmail.com> | 2015-09-21 16:33:32 -0400 |
---|---|---|
committer | Ceridwen <ceridwenv@gmail.com> | 2015-09-21 16:33:32 -0400 |
commit | 5789efaa3963569bc1060cfee5f15726d806e70c (patch) | |
tree | 34806989657c0f66f1afb338d1fc8508ce18909b /astroid/inference.py | |
parent | 93fb564e69b77c1b697e942f39de3bdd1172399b (diff) | |
download | astroid-5789efaa3963569bc1060cfee5f15726d806e70c.tar.gz |
Add helper function for reraising exceptions
Diffstat (limited to 'astroid/inference.py')
-rw-r--r-- | astroid/inference.py | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/astroid/inference.py b/astroid/inference.py index e704252..df32c04 100644 --- a/astroid/inference.py +++ b/astroid/inference.py @@ -25,7 +25,6 @@ from __future__ import print_function import functools import itertools import operator -import sys import six @@ -163,9 +162,7 @@ def infer_import_from(self, context=None, asname=True): stmts = module.getattr(name, ignore_locals=module is self.root()) return bases._infer_stmts(stmts, context) except exceptions.NotFoundError: - six.reraise(exceptions.InferenceError, - exceptions.InferenceError(name), - sys.exc_info()[2]) + util.reraise(exceptions.InferenceError(name)) nodes.ImportFrom._infer = infer_import_from @@ -198,9 +195,7 @@ def infer_global(self, context=None): return bases._infer_stmts(self.root().getattr(context.lookupname), context) except exceptions.NotFoundError: - six.reraise(exceptions.InferenceError, - exceptions.InferenceError(), - sys.exc_info()[2]) + util.reraise(exceptions.InferenceError()) nodes.Global._infer = infer_global @@ -270,9 +265,7 @@ def infer_subscript(self, context=None): try: assigned = value.getitem(index_value, context) except (IndexError, TypeError, AttributeError) as exc: - six.reraise(exceptions.InferenceError, - exceptions.InferenceError(*exc.args), - sys.exc_info()[2]) + util.reraise(exceptions.InferenceError(*exc.args)) # Prevent inferring if the inferred subscript # is the same as the original subscripted object. @@ -721,8 +714,6 @@ def instance_getitem(self, index, context=None): try: return next(method.infer_call_result(self, new_context)) except StopIteration: - six.reraise(exceptions.InferenceError, - exceptions.InferenceError(), - sys.exc_info()[2]) + util.reraise(exceptions.InferenceError()) bases.Instance.getitem = instance_getitem |