jedi#setup_python_imports: better SyntaxError handling

Uses `repr` for SyntaxErrors.

Related: https://github.com/neovim/python-client/pull/221
This commit is contained in:
Daniel Hahler
2018-06-23 09:03:44 +02:00
committed by Dave Halter
parent 84a5299c8f
commit 745dc8a559

View File

@@ -112,7 +112,11 @@ function! jedi#setup_python_imports(py_version) abort
\ 'try:',
\ ' import jedi_vim',
\ 'except Exception as exc:',
\ ' vim.command(''let s:init_outcome = "could not import jedi_vim: {0}: {1}"''.format(exc.__class__.__name__, exc))',
\ ' if isinstance(exc, SyntaxError):',
\ ' exc_msg = repr(exc)',
\ ' else:',
\ ' exc_msg = "%s: %s" % (exc.__class__.__name__, exc)',
\ ' vim.command(''let s:init_outcome = "could not import jedi_vim: {0}"''.format(exc_msg))',
\ 'else:',
\ ' vim.command(''let s:init_outcome = 1'')']
try