Use python’s try/catch, not vim’s

Fixes #344
This commit is contained in:
ZyX 2013-03-22 16:50:06 +04:00
parent 127a600e1b
commit e151b600b2

View File

@ -21,24 +21,23 @@ let s:powerline_pyeval = get(g:, 'powerline_pyeval', s:powerline_pycmd.'eval')
let s:import_cmd = 'from powerline.vim import VimPowerline' let s:import_cmd = 'from powerline.vim import VimPowerline'
try try
exec s:powerline_pycmd s:import_cmd exec s:powerline_pycmd "try:\n"
catch \ ." ".s:import_cmd."\n"
" An error occurred while importing the module, it could be installed \ ."except ImportError:\n"
" outside of Python's module search paths. Update sys.path and try again. \ ." import sys, vim\n"
exec s:powerline_pycmd 'import sys, vim' \ ." sys.path.append(vim.eval('expand(\"<sfile>:h:h:h:h:h\")'))\n"
exec s:powerline_pycmd 'sys.path.append(vim.eval(''expand("<sfile>:h:h:h:h:h")''))' \ ." ".s:import_cmd
try let s:launched = 1
exec s:powerline_pycmd s:import_cmd finally
let s:launched = 1 if !exists('s:launched')
finally call s:CriticalError('An error occurred while importing the Powerline package.
if !exists('s:launched') \ This could be caused by an invalid sys.path setting, or by an incompatible
call s:CriticalError('An error occurred while importing the Powerline package. \ Python version (Powerline requires Python 2.6+ or 3.2+ to work). Please consult
\ This could be caused by an invalid sys.path setting, or by an incompatible \ the troubleshooting section in the documentation for possible solutions.')
\ Python version (Powerline requires Python 2.6+ or 3.2+ to work). Please consult finish
\ the troubleshooting section in the documentation for possible solutions.') else
finish unlet s:launched
endif endif
endtry
endtry endtry
if !get(g:, 'powerline_debugging_pyeval') && exists('*'. s:powerline_pyeval) if !get(g:, 'powerline_debugging_pyeval') && exists('*'. s:powerline_pyeval)