init: improve handling of import errors (#840)

* jedi_vim.jedi_import_error: add location

This is useful for debugging.  It contains e.g. the path to parso, if
importing failed from there.

Example:

> Error: jedi-vim failed to initialize Python: jedi#setup_python_imports: could not import jedi: cannot import name 'PythonTokenTypes' (in /…/jedi-vim/pythonx/jedi/jedi/api/completion.py:1). (in function jedi#init_python[3]..<SNR>44_init_python[27]..jedi#setup_python_imports, line 37)

* init: handle jedi_vim.jedi_import_error in Vim plugin

Using `set shortmess+=F` would suppress the `:echom` used in
`jedi_vim.no_jedi_warning` [1].

This patch makes `jedi#setup_python_imports` handle the error instead.

1: https://github.com/neovim/neovim/issues/8675

* Revisit error handling with loading jedi_vim

* jedi#debug_info: display parso submodule separately

* Fix jedi#reinit_python

* fixup! Revisit error handling with loading jedi_vim

* display_debug_info: handle exceptions with environment.get_sys_path

* fixup! Revisit error handling with loading jedi_vim

[ci skip]
This commit is contained in:
Daniel Hahler
2018-07-04 22:12:07 +02:00
committed by Dave Halter
parent 0361d6c633
commit d3d9a91ae6
4 changed files with 109 additions and 72 deletions

View File

@@ -110,10 +110,9 @@ sys.path.insert(0, parso_path)
try:
import jedi
except ImportError as e:
no_jedi_warning(str(e))
except ImportError:
jedi = None
jedi_import_error = str(e)
jedi_import_error = sys.exc_info()
else:
try:
version = jedi.__version__