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 | 18fc67e6f514daf584137e20857ebd4ef22aa3ad (patch) | |
| tree | 4a58c7d4c2abb965f0d66559247065ffe89441ae /astroid/manager.py | |
| parent | a1dcb2d18a65be6034459832c91bc5eacbee3c1e (diff) | |
| download | astroid-git-18fc67e6f514daf584137e20857ebd4ef22aa3ad.tar.gz | |
Add helper function for reraising exceptions
Diffstat (limited to 'astroid/manager.py')
| -rw-r--r-- | astroid/manager.py | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/astroid/manager.py b/astroid/manager.py index 266dd281..6752717e 100644 --- a/astroid/manager.py +++ b/astroid/manager.py @@ -31,6 +31,7 @@ import six from astroid import exceptions from astroid import modutils from astroid import transforms +from astroid import util def safe_repr(obj): @@ -128,9 +129,7 @@ class AstroidManager(object): module = modutils.load_module_from_name(modname) except Exception as ex: msg = 'Unable to load module %s (%s)' % (modname, ex) - six.reraise(exceptions.AstroidBuildingException, - exceptions.AstroidBuildingException(msg), - sys.exc_info()[2]) + util.reraise(exceptions.AstroidBuildingException(msg)) return self.ast_from_module(module, modname) elif mp_type == imp.PY_COMPILED: msg = "Unable to load compiled module %s" % (modname,) @@ -212,9 +211,7 @@ class AstroidManager(object): modname = klass.__module__ except AttributeError: msg = 'Unable to get module for class %s' % safe_repr(klass) - six.reraise(exceptions.AstroidBuildingException, - exceptions.AstroidBuildingException(msg), - sys.exc_info()[2]) + util.reraise(exceptions.AstroidBuildingException(msg)) modastroid = self.ast_from_module_name(modname) return modastroid.getattr(klass.__name__)[0] # XXX @@ -228,28 +225,20 @@ class AstroidManager(object): modname = klass.__module__ except AttributeError: msg = 'Unable to get module for %s' % safe_repr(klass) - six.reraise(exceptions.AstroidBuildingException, - exceptions.AstroidBuildingException(msg), - sys.exc_info()[2]) + util.reraise(exceptions.AstroidBuildingException(msg)) except Exception as ex: msg = ('Unexpected error while retrieving module for %s: %s' % (safe_repr(klass), ex)) - six.reraise(exceptions.AstroidBuildingException, - exceptions.AstroidBuildingException(msg), - sys.exc_info()[2]) + util.reraise(exceptions.AstroidBuildingException(msg)) try: name = klass.__name__ except AttributeError: msg = 'Unable to get name for %s' % safe_repr(klass) - six.reraise(exceptions.AstroidBuildingException, - exceptions.AstroidBuildingException(msg), - sys.exc_info()[2]) + util.reraise(exceptions.AstroidBuildingException(msg)) except Exception as ex: exc = ('Unexpected error while retrieving name for %s: %s' % (safe_repr(klass), ex)) - six.reraise(exceptions.AstroidBuildingException, - exceptions.AstroidBuildingException(exc), - sys.exc_info()[2]) + util.reraise(exceptions.AstroidBuildingException(exc)) # take care, on living object __module__ is regularly wrong :( modastroid = self.ast_from_module_name(modname) if klass is obj: |
