1
0
forked from VimPlug/jedi

Make sure to not load unsafe modules anymore if they are not on the sys path, fixes #760

This commit is contained in:
Dave Halter
2020-01-31 13:09:28 +01:00
parent e7a77e438d
commit 8ff2ea4b38
6 changed files with 56 additions and 23 deletions

View File

@@ -142,7 +142,7 @@ class InferenceState(object):
def get_sys_path(self, **kwargs):
"""Convenience function"""
return self.project._get_sys_path(self, environment=self.environment, **kwargs)
return self.project._get_sys_path(self, **kwargs)
def infer(self, context, name):
def_ = name.get_definition(import_name_always=True)

View File

@@ -454,8 +454,12 @@ def _load_python_module(inference_state, file_io,
def _load_builtin_module(inference_state, import_names=None, sys_path=None):
project = inference_state.project
if sys_path is None:
sys_path = inference_state.get_sys_path()
if not project._load_unsafe_extensions:
safe_paths = project._get_base_sys_path(inference_state)
sys_path = [p for p in sys_path if p in safe_paths]
dotted_name = '.'.join(import_names)
assert dotted_name is not None