mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-15 23:07:08 +08:00
Improve/harden jedi#setup_python_imports
In particular it should not try to import `jedi_vim_debug` during error handling "unprotected", which might hide the real error on Python 2 at least. Ref: https://github.com/davidhalter/jedi-vim/issues/998#issuecomment-592305240
This commit is contained in:
committed by
Dave Halter
parent
686f39ac00
commit
b2e8c65e35
@@ -160,14 +160,19 @@ function! jedi#setup_python_imports(py_version) abort
|
||||
let g:_jedi_init_error = 0
|
||||
let init_lines = [
|
||||
\ 'import vim',
|
||||
\ 'def _jedi_handle_exc(exc_info):',
|
||||
\ ' try:',
|
||||
\ ' from jedi_vim_debug import format_exc_info',
|
||||
\ ' vim.vars["_jedi_init_error"] = format_exc_info(exc_info)',
|
||||
\ ' except Exception:',
|
||||
\ ' import traceback',
|
||||
\ ' vim.vars["_jedi_init_error"] = "\\n".join(traceback.format_exception(*exc_info))',
|
||||
\ 'try:',
|
||||
\ ' import jedi_vim',
|
||||
\ ' if hasattr(jedi_vim, "jedi_import_error"):',
|
||||
\ ' from jedi_vim_debug import format_exc_info',
|
||||
\ ' vim.vars["_jedi_init_error"] = format_exc_info(jedi_vim.jedi_import_error)',
|
||||
\ ' _jedi_handle_exc(jedi_vim.jedi_import_error)',
|
||||
\ 'except Exception as exc:',
|
||||
\ ' from jedi_vim_debug import format_exc_info',
|
||||
\ ' vim.vars["_jedi_init_error"] = format_exc_info()',
|
||||
\ ' _jedi_handle_exc(sys.exc_info())',
|
||||
\ ]
|
||||
exe 'PythonJedi exec('''.escape(join(init_lines, '\n'), "'").''')'
|
||||
if g:_jedi_init_error isnot 0
|
||||
|
||||
Reference in New Issue
Block a user