Skip to content

Commit

Permalink
attach: auto decode if python3
Browse files Browse the repository at this point in the history
  • Loading branch information
bfredl committed Mar 29, 2016
1 parent 0886e84 commit 02e28e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 7 additions & 2 deletions neovim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import sys

from .api import Nvim
from .compat import IS_PYTHON3
from .msgpack_rpc import (ErrorResponse, child_session, socket_session,
stdio_session, tcp_session)
from .plugin import (Host, autocmd, command, decode, encoding, function,
Expand Down Expand Up @@ -63,7 +64,8 @@ def start_host(session=None):
host.start(plugins)


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

return Nvim.from_session(session)
if decode is None:
decode = IS_PYTHON3

return Nvim.from_session(session).with_decode(decode)


def setup_logging():
Expand Down
5 changes: 0 additions & 5 deletions test/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
else:
vim = neovim.attach('socket', path=listen_address)

if sys.version_info >= (3, 0):
# For Python3 we decode binary strings as Unicode for compatibility
# with Python2
vim = vim.with_decode()

cleanup_func = ''':function BeforeEachTest()
set all&
redir => groups
Expand Down

0 comments on commit 02e28e7

Please sign in to comment.