From 3497a9644e12a90474c8ec1ccbd609e5f02cb36f Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Tue, 14 Apr 2015 20:11:50 +0200 Subject: [PATCH] jedi#force_py_version: catch errors This prevents the script from aborting, in case e.g. `py3file` is not defined, but should be forced. --- autoload/jedi.vim | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/autoload/jedi.vim b/autoload/jedi.vim index 0479573..b879452 100644 --- a/autoload/jedi.vim +++ b/autoload/jedi.vim @@ -256,13 +256,19 @@ endfunction function! jedi#force_py_version(py_version) let g:jedi#force_py_version = a:py_version - if g:jedi#force_py_version == 2 - command! -nargs=1 Python python - execute 'pyfile '.s:script_path.'/initialize.py' - elseif g:jedi#force_py_version == 3 - command! -nargs=1 Python python3 - execute 'py3file '.s:script_path.'/initialize.py' - endif + try + if g:jedi#force_py_version == 2 + command! -nargs=1 Python python + execute 'pyfile '.s:script_path.'/initialize.py' + elseif g:jedi#force_py_version == 3 + command! -nargs=1 Python python3 + execute 'py3file '.s:script_path.'/initialize.py' + endif + catch + if !exists("g:jedi#squelch_py_warning") + echom "jedi#force_py_version failed: " . v:exception + endif + endtry endfunction