From 745dc8a5594bcebab2b16510832804843bdde737 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 23 Jun 2018 09:03:44 +0200 Subject: [PATCH] jedi#setup_python_imports: better SyntaxError handling Uses `repr` for SyntaxErrors. Related: https://github.com/neovim/python-client/pull/221 --- autoload/jedi.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autoload/jedi.vim b/autoload/jedi.vim index d35dce0..d93c248 100644 --- a/autoload/jedi.vim +++ b/autoload/jedi.vim @@ -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