Skip to content

Commit 02e28e7

Browse files
committed
attach: auto decode if python3
1 parent 0886e84 commit 02e28e7

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

neovim/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import sys
88

99
from .api import Nvim
10+
from .compat import IS_PYTHON3
1011
from .msgpack_rpc import (ErrorResponse, child_session, socket_session,
1112
stdio_session, tcp_session)
1213
from .plugin import (Host, autocmd, command, decode, encoding, function,
@@ -63,7 +64,8 @@ def start_host(session=None):
6364
host.start(plugins)
6465

6566

66-
def attach(session_type, address=None, port=None, path=None, argv=None):
67+
def attach(session_type, address=None, port=None,
68+
path=None, argv=None, decode=None):
6769
"""Provide a nicer interface to create python api sessions.
6870
6971
Previous machinery to create python api sessions is still there. This only
@@ -89,7 +91,10 @@ def attach(session_type, address=None, port=None, path=None, argv=None):
8991
if not session:
9092
raise Exception('Unknown session type "%s"' % session_type)
9193

92-
return Nvim.from_session(session)
94+
if decode is None:
95+
decode = IS_PYTHON3
96+
97+
return Nvim.from_session(session).with_decode(decode)
9398

9499

95100
def setup_logging():

test/test_common.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@
1818
else:
1919
vim = neovim.attach('socket', path=listen_address)
2020

21-
if sys.version_info >= (3, 0):
22-
# For Python3 we decode binary strings as Unicode for compatibility
23-
# with Python2
24-
vim = vim.with_decode()
25-
2621
cleanup_func = ''':function BeforeEachTest()
2722
set all&
2823
redir => groups

0 commit comments

Comments
 (0)