forked from VimPlug/jedi
Do not cache unimportable compiled module (#1079)
From the issue:
The issue can be reproduced by getting the description of the QtBluetooth module from PyQt5 on Windows:
import jedi
completions = jedi.Script('import PyQt5.QtBlueTooth').completions()
completions[0].description
It's hard to write a test for it so we don't write one for it.
This commit is contained in:
@@ -500,19 +500,21 @@ def _load_module(evaluator, path=None, code=None, sys_path=None,
|
||||
)
|
||||
else:
|
||||
module = compiled.load_module(evaluator, path=path, sys_path=sys_path)
|
||||
add_module(evaluator, module_name, module, safe=safe_module_name)
|
||||
|
||||
if module_name is not None and module is not None:
|
||||
add_module(evaluator, module_name, module, safe=safe_module_name)
|
||||
|
||||
return module
|
||||
|
||||
|
||||
def add_module(evaluator, module_name, module, safe=False):
|
||||
if module_name is not None:
|
||||
if not safe and '.' not in module_name:
|
||||
# We cannot add paths with dots, because that would collide with
|
||||
# the sepatator dots for nested packages. Therefore we return
|
||||
# `__main__` in ModuleWrapper.py__name__(), which is similar to
|
||||
# Python behavior.
|
||||
return
|
||||
evaluator.module_cache.add(module, module_name)
|
||||
if not safe and '.' not in module_name:
|
||||
# We cannot add paths with dots, because that would collide with
|
||||
# the sepatator dots for nested packages. Therefore we return
|
||||
# `__main__` in ModuleWrapper.py__name__(), which is similar to
|
||||
# Python behavior.
|
||||
return
|
||||
evaluator.module_cache.add(module, module_name)
|
||||
|
||||
|
||||
def get_modules_containing_name(evaluator, modules, name):
|
||||
|
||||
Reference in New Issue
Block a user