summaryrefslogtreecommitdiff
path: root/astroid/mixins.py
diff options
context:
space:
mode:
authorClaudiu Popa <cpopa@cloudbasesolutions.com>2015-07-14 00:13:31 +0300
committerClaudiu Popa <cpopa@cloudbasesolutions.com>2015-07-14 00:13:31 +0300
commit642723c222ae6701d6b8da17039b6e24fd09f235 (patch)
tree1c9dd5351dab91d903d3aebd14ebf1401e244758 /astroid/mixins.py
parentb1824e8f74232fac14e2600c28d53a320a94510e (diff)
downloadastroid-git-642723c222ae6701d6b8da17039b6e24fd09f235.tar.gz
do_import_module passes the proper relative_only flag if the level is higher than 1.
This has the side effect that using `from .something import something` in a non-package will finally result in an import-error on Pylint's side. Until now relative_only was ignored, leading to the import of `something`, if it was globally available.
Diffstat (limited to 'astroid/mixins.py')
-rw-r--r--astroid/mixins.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/astroid/mixins.py b/astroid/mixins.py
index 185ff16c..e7021906 100644
--- a/astroid/mixins.py
+++ b/astroid/mixins.py
@@ -104,7 +104,8 @@ class FromImportMixIn(FilterStmtsMixin):
# FIXME: we used to raise InferenceError here, but why ?
return mymodule
try:
- return mymodule.import_module(modname, level=level)
+ return mymodule.import_module(modname, level=level,
+ relative_only=level and level >= 1)
except AstroidBuildingException as ex:
if isinstance(ex.args[0], SyntaxError):
raise InferenceError(str(ex))