diff options
author | Mario Corchero <mcorcherojim@bloomberg.net> | 2018-07-04 22:16:23 +0100 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2018-07-05 11:28:11 +0200 |
commit | 6917550911c2158e41f5c5e97a42cb3818319e94 (patch) | |
tree | 865122cf1127a3ea5bc9b5f842fe1f28f659a3d3 /astroid/modutils.py | |
parent | 82b7687e1a72dc1ca8a9256f3696d83a64136ba0 (diff) | |
download | astroid-git-6917550911c2158e41f5c5e97a42cb3818319e94.tar.gz |
Include abspath of sys.path on searches at load_from_module
At the moment `load_from_module` is resolving all paths in `sys.path`
to validate that the module being import is in a folder part of the
path. This is done to resolve symlinks.
This can be an issue though it both the file being imported and the path
in `sys.path` resolve to different locations. Even if the symlinks are
importable, the resolution of the paths in `sys.path` might not.
Diffstat (limited to 'astroid/modutils.py')
-rw-r--r-- | astroid/modutils.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/astroid/modutils.py b/astroid/modutils.py index edabcd5b..03c0f292 100644 --- a/astroid/modutils.py +++ b/astroid/modutils.py @@ -23,6 +23,7 @@ import imp import os import platform import sys +import itertools from distutils.sysconfig import get_python_lib # pylint: disable=import-error # pylint: disable=import-error, no-name-in-module from distutils.errors import DistutilsPlatformError @@ -320,7 +321,8 @@ def modpath_from_file_with_callback(filename, extrapath=None, is_package_cb=None filename = os.path.expanduser(_path_from_filename(filename)) if extrapath is not None: - for path_ in map(_canonicalize_path, extrapath): + for path_ in itertools.chain(map(_canonicalize_path, extrapath), + extrapath): path = os.path.abspath(path_) if not path: continue @@ -330,7 +332,7 @@ def modpath_from_file_with_callback(filename, extrapath=None, is_package_cb=None if is_package_cb(path, submodpath[:-1]): return extrapath[path_].split('.') + submodpath - for path in map(_canonicalize_path, sys.path): + for path in itertools.chain(map(_canonicalize_path, sys.path), sys.path): path = _cache_normalize_path(path) if not path: continue |