Skip to content

Commit

Permalink
fix problems with error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhalter committed Aug 28, 2013
1 parent c3f9f03 commit 02a7c89
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions jedi_vim.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import vim
import jedi
import jedi.keywords
from jedi._compatibility import unicode
from jedi._compatibility import unicode, is_py3k


def catch_and_print_exceptions(func):
Expand Down Expand Up @@ -40,7 +40,7 @@ def _catch_exception(string, is_eval):
Necessary, because the exact error message is not given by `vim.error`.
"""
e = 'jedi#_vim_exceptions(%s, %s)'
result = vim.eval(e % (repr(PythonToVimStr(string)), is_eval))
result = vim.eval(e % (repr(PythonToVimStr(string, 'UTF-8')), is_eval))
if 'exception' in result:
raise VimError(result['exception'], result['throwpoint'], string)
return result['result']
Expand All @@ -65,6 +65,11 @@ def echo_highlight(msg):
class PythonToVimStr(unicode):
""" Vim has a different string implementation of single quotes """
__slots__ = []
def __new__(cls, obj, encoding='UTF-8'):
if is_py3k or isinstance(obj, unicode):
return unicode.__new__(cls, obj)
else:
return unicode.__new__(cls, obj, encoding)

def __repr__(self):
# this is totally stupid and makes no sense but vim/python unicode
Expand Down

0 comments on commit 02a7c89

Please sign in to comment.