maralla/completor.vim

LSP binary input to json.loads

Closed this issue · 0 comments

Using the latest LSP support update #254 with python3.5 and the following configuration yields a Traceback upon trigger.

let g:completor_filetype_map = {
      \ 'go':   {'ft': 'lsp', 'cmd': 'gopls'},
      \ }
Traceback (most recent call last):
Error detected while processing function <lambda>19[1]..<SNR>192_vim_daemon_handler[1]..completor#action#stream[1]..completor#utils#on_stream[1]..<lambda>19[1]..<SNR>192_vim_daemon_handler[1]..completor#action#stream[1]..completor#
utils#on_stream:
line    1:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/huntrar/.vim/plugged/completor.vim/pythonx/completor/api.py", line 14, in wrapper
    return func(vim.bindeval('a:'))
  File "/home/huntrar/.vim/plugged/completor.vim/pythonx/completor/api.py", line 78, in on_stream
    c.handle_stream(args['action'], args['msg'])
  File "/home/huntrar/.vim/plugged/completor.vim/pythonx/completor/__init__.py", line 220, in handle_stream
    res = self.on_stream(action, msg)
  File "/home/huntrar/.vim/plugged/completor.vim/pythonx/completers/lsp/__init__.py", line 214, in on_stream
    for item in self.parse_data():
  File "/home/huntrar/.vim/plugged/completor.vim/pythonx/completers/lsp/__init__.py", line 174, in parse_data
    yield json.loads(data)
  File "/usr/lib/python3.5/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'

Support for binary input to json.loads was added in python3.6.

The issue seems resolvable by UTF-8 decoding the bytes object before decoding the JSON.