Skip to content

Commit 97b343b

Browse files
authored
errors: decode bytes (#412)
1 parent a63cddb commit 97b343b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pynvim/api/nvim.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def from_session(cls, session):
7676
queries Nvim metadata for type information and sets a SessionHook for
7777
creating specialized objects from Nvim remote handles.
7878
"""
79-
session.error_wrapper = lambda e: NvimError(e[1])
79+
session.error_wrapper = lambda e: NvimError(decode_if_bytes(e[1]))
8080
channel_id, metadata = session.request(b'nvim_get_api_info')
8181

8282
if IS_PYTHON3:

test/test_vim.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import sys
44
import tempfile
55

6+
import pytest
7+
68

79
def source(vim, code):
810
fd, fname = tempfile.mkstemp()
@@ -34,6 +36,12 @@ def test_command_output(vim):
3436
assert vim.command_output('echo "test"') == 'test'
3537

3638

39+
def test_command_error(vim):
40+
with pytest.raises(vim.error) as excinfo:
41+
vim.current.window.cursor = -1, -1
42+
assert excinfo.value.args == ('Cursor position outside buffer',)
43+
44+
3745
def test_eval(vim):
3846
vim.command('let g:v1 = "a"')
3947
vim.command('let g:v2 = [1, 2, {"v3": 3}]')

0 commit comments

Comments
 (0)