Skip to content

Commit a93c1a5

Browse files
committed
Automatic Unicode decoding for python3 plugins
- In Vim :py3 returns unicode strings to the caller, for compatibility automatic decoding is now enabled for plugins in python3
1 parent 6908198 commit a93c1a5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

neovim/plugins/script_host.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import logging
33
import sys
44

5-
from ..api.common import SessionHook
5+
from ..api.common import SessionHook, DecodeHook
66
from ..compat import NUM_TYPES, IS_PYTHON3
77

88

@@ -26,6 +26,8 @@ def __init__(self, nvim):
2626
# it seems some plugins assume 'sys' is already imported, so do it now
2727
exec('import sys', self.module.__dict__)
2828
sys.modules['vim'] = nvim.with_hook(LegacyEvalHook())
29+
if IS_PYTHON3:
30+
sys.modules['vim'] = sys.modules['vim'].with_hook(DecodeHook(encoding=nvim.options['encoding'].decode('ascii')))
2931

3032
def python_execute(self, script):
3133
exec(script, self.module.__dict__)

0 commit comments

Comments
 (0)