diff --git a/jedi/builtin.py b/jedi/builtin.py index 64e59d62..1792555d 100644 --- a/jedi/builtin.py +++ b/jedi/builtin.py @@ -13,8 +13,8 @@ import debug import parsing -module_find_path = sys.path[1:] - +def get_sys_path(): + return sys.path[1:] class CachedModule(object): """ @@ -84,7 +84,9 @@ class Parser(CachedModule): module_cache = {} - def __init__(self, path=None, name=None, sys_path=module_find_path): + def __init__(self, path=None, name=None, sys_path=None): + if sys_path is None: + sys_path = get_sys_path() if not name: name = os.path.basename(path) name = name.rpartition('.')[0] # cut file type (normally .so) diff --git a/jedi/imports.py b/jedi/imports.py index c54ae694..23cbed71 100644 --- a/jedi/imports.py +++ b/jedi/imports.py @@ -211,7 +211,7 @@ class ImportPath(object): sys_path_mod = list(self.sys_path_with_modifications()) sys_path_mod.insert(0, self.file_path) else: - sys_path_mod = list(builtin.module_find_path) + sys_path_mod = list(builtin.get_sys_path()) current_namespace = None # now execute those paths diff --git a/jedi/modules.py b/jedi/modules.py index c0918bb9..cee0f49d 100644 --- a/jedi/modules.py +++ b/jedi/modules.py @@ -234,9 +234,9 @@ def sys_path_with_modifications(module): try: possible_stmts = module.used_names['path'] except KeyError: - return builtin.module_find_path + return builtin.get_sys_path() - sys_path = list(builtin.module_find_path) # copy + sys_path = list(builtin.get_sys_path()) # copy for p in possible_stmts: try: call = p.get_assignment_calls().get_only_subelement()