mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
Fix sys_path propagation for builtins load_module
This commit is contained in:
@@ -28,8 +28,8 @@ def get_special_object(evaluator, identifier):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def load_module(evaluator, path=None, name=None):
|
def load_module(evaluator, **kwargs):
|
||||||
access_path = evaluator.compiled_subprocess.load_module(path=path, name=name)
|
access_path = evaluator.compiled_subprocess.load_module(**kwargs)
|
||||||
if access_path is None:
|
if access_path is None:
|
||||||
return None
|
return None
|
||||||
return create_from_access_path(evaluator, access_path)
|
return create_from_access_path(evaluator, access_path)
|
||||||
|
|||||||
@@ -118,8 +118,9 @@ def create_access(evaluator, obj):
|
|||||||
return evaluator.compiled_subprocess.get_or_create_access_handle(obj)
|
return evaluator.compiled_subprocess.get_or_create_access_handle(obj)
|
||||||
|
|
||||||
|
|
||||||
def load_module(evaluator, path=None, name=None):
|
def load_module(evaluator, path=None, name=None, sys_path=None):
|
||||||
sys_path = list(evaluator.project.sys_path)
|
if sys_path is None:
|
||||||
|
sys_path = list(evaluator.project.sys_path)
|
||||||
if path is not None:
|
if path is not None:
|
||||||
dotted_path = dotted_from_fs_path(path, sys_path=sys_path)
|
dotted_path = dotted_from_fs_path(path, sys_path=sys_path)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ def get_sys_path():
|
|||||||
return sys.path
|
return sys.path
|
||||||
|
|
||||||
|
|
||||||
def load_module(evaluator, path=None, name=None):
|
def load_module(evaluator, **kwargs):
|
||||||
return access.load_module(evaluator, path=path, name=name)
|
return access.load_module(evaluator, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def get_compiled_method_return(evaluator, id, attribute, *args, **kwargs):
|
def get_compiled_method_return(evaluator, id, attribute, *args, **kwargs):
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ class Importer(object):
|
|||||||
elif module_file is not None or module_path.endswith(('.py', '.zip', '.egg')):
|
elif module_file is not None or module_path.endswith(('.py', '.zip', '.egg')):
|
||||||
module = _load_module(self._evaluator, module_path, code, sys_path, parent_module)
|
module = _load_module(self._evaluator, module_path, code, sys_path, parent_module)
|
||||||
else:
|
else:
|
||||||
module = compiled.load_module(self._evaluator, path=module_path)
|
module = compiled.load_module(self._evaluator, path=module_path, sys_path=sys_path)
|
||||||
|
|
||||||
if module is None:
|
if module is None:
|
||||||
# The file might raise an ImportError e.g. and therefore not be
|
# The file might raise an ImportError e.g. and therefore not be
|
||||||
@@ -491,7 +491,7 @@ def _load_module(evaluator, path=None, code=None, sys_path=None, parent_module=N
|
|||||||
from jedi.evaluate.context import ModuleContext
|
from jedi.evaluate.context import ModuleContext
|
||||||
return ModuleContext(evaluator, module_node, path=path)
|
return ModuleContext(evaluator, module_node, path=path)
|
||||||
else:
|
else:
|
||||||
return compiled.load_module(evaluator, path)
|
return compiled.load_module(evaluator, path=path, sys_path=sys_path)
|
||||||
|
|
||||||
|
|
||||||
def add_module(evaluator, module_name, module):
|
def add_module(evaluator, module_name, module):
|
||||||
|
|||||||
Reference in New Issue
Block a user