jedi#force_py_version: catch errors

This prevents the script from aborting, in case e.g. `py3file` is not
defined, but should be forced.
This commit is contained in:
Daniel Hahler
2015-04-14 20:11:50 +02:00
parent 0cd664d8f7
commit 3497a9644e

View File

@@ -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 <args>
execute 'pyfile '.s:script_path.'/initialize.py'
elseif g:jedi#force_py_version == 3
command! -nargs=1 Python python3 <args>
execute 'py3file '.s:script_path.'/initialize.py'
endif
try
if g:jedi#force_py_version == 2
command! -nargs=1 Python python <args>
execute 'pyfile '.s:script_path.'/initialize.py'
elseif g:jedi#force_py_version == 3
command! -nargs=1 Python python3 <args>
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