mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-07 03:04:30 +08:00
VIM apparently cannot deal with zero bytes in strings. Fixes #551
This commit is contained in:
10
jedi_vim.py
10
jedi_vim.py
@@ -30,10 +30,12 @@ class PythonToVimStr(unicode):
|
|||||||
__slots__ = []
|
__slots__ = []
|
||||||
|
|
||||||
def __new__(cls, obj, encoding='UTF-8'):
|
def __new__(cls, obj, encoding='UTF-8'):
|
||||||
if is_py3 or isinstance(obj, unicode):
|
if not (is_py3 or isinstance(obj, unicode)):
|
||||||
return unicode.__new__(cls, obj)
|
obj = unicode.__new__(cls, obj, encoding)
|
||||||
else:
|
|
||||||
return unicode.__new__(cls, obj, encoding)
|
# Vim cannot deal with zero bytes:
|
||||||
|
obj = obj.replace('\0', '\\0')
|
||||||
|
return unicode.__new__(cls, obj)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
# this is totally stupid and makes no sense but vim/python unicode
|
# this is totally stupid and makes no sense but vim/python unicode
|
||||||
|
|||||||
Reference in New Issue
Block a user