summaryrefslogtreecommitdiff
path: root/astroid/mixins.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2015-12-06 17:06:11 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2015-12-06 17:06:11 +0200
commit4ef9c896f4f8835dc1d49c70844fbc9337b24f93 (patch)
tree271b200cb901668d8c5ab15c523a2efd97ca258e /astroid/mixins.py
parentb3d48abbdf673697977f59c5476008a85acb1e27 (diff)
downloadastroid-git-4ef9c896f4f8835dc1d49c70844fbc9337b24f93.tar.gz
Add two new exceptions, AstroidImportError and AstroidSyntaxError.
They are subclasses of AstroidBuildingException and are raised when a module can't be imported from various reasons. Also do_import_module lets the errors to bubble up without converting them to InferenceError. This particular conversion happens only during the inference.
Diffstat (limited to 'astroid/mixins.py')
-rw-r--r--astroid/mixins.py20
1 files changed, 3 insertions, 17 deletions
diff --git a/astroid/mixins.py b/astroid/mixins.py
index 6ee7b4db..e67c9af3 100644
--- a/astroid/mixins.py
+++ b/astroid/mixins.py
@@ -125,23 +125,9 @@ class ImportFromMixin(FilterStmtsMixin):
if mymodule.relative_to_absolute_name(modname, level) == mymodule.name:
# FIXME: we used to raise InferenceError here, but why ?
return mymodule
- try:
- return mymodule.import_module(modname, level=level,
- relative_only=level and level >= 1)
- except exceptions.AstroidBuildingException as ex:
- if isinstance(getattr(ex, 'error', None), SyntaxError):
- util.reraise(exceptions.InferenceError(
- 'Could not import {modname} because of SyntaxError:\n'
- '{syntax_error}', modname=modname, syntax_error=ex.error,
- import_node=self))
- util.reraise(exceptions.InferenceError('Could not import {modname}.',
- modname=modname,
- import_node=self))
- except SyntaxError as ex:
- util.reraise(exceptions.InferenceError(
- 'Could not import {modname} because of SyntaxError:\n'
- '{syntax_error}', modname=modname, syntax_error=ex,
- import_node=self))
+
+ return mymodule.import_module(modname, level=level,
+ relative_only=level and level >= 1)
def real_name(self, asname):
"""get name from 'as' name"""