WolfgangMehner / vim-plugins

Vim plug-ins which offer support for various programming languages.
414 stars 96 forks source link

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc2 in position 0: unexpected end of data #30

Open wgwang opened 8 years ago

wgwang commented 8 years ago

In Ubuntu 16.04, the plugin will cause the other plugins raising UnicodeDecodeError when the plugins execute python code vim.eval(g:) and other similar codes.

There are some compatibility in the pugin. If vim with python3 support loading the plugin, try the command python3 vim.eval('extend(g:, {})') in vim ex mode, it will raise the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc2 in position 0: unexpected end of data

And python support has the same problem.

WolfgangMehner commented 8 years ago

This seems to be a problem with the Python interface rather than our plug-in. Our plug-in creates a data structure containing a string '\xc2' somewhere, which is a perfectly valid operation in VimScript. On the other hand, the UnicodeDecodeError seems very common in Python (which has probably something to do with the "Very High Level Embedding" and the fact that you have to serialize all data to transfer it into the Python state.)

Could you please name some of the plug-ins causing these problems? I would like to get a better overview of the issue.

wgwang commented 8 years ago

This is the only one which raise the error.

I try the following commands, and they appear to be collect.

:py3 vim.command('let g:abc="\xc2"')
:py3 print(vim.eval('g:abc'))

So, I think there is some other problem in the plugin. Beside, I grep the code with '\xc2' and 'Â' in the repository, but nothing found. Could you tell me the full path of the structure ?

WolfgangMehner commented 8 years ago

Sorry, a lot to do recently. Let me come back to this.

Could you please name some of the plug-ins causing these problems? I would like to get a better overview of the issue.

What I meant by this is:

Which plug-ins are using the call python3 vim.eval('extend(g:, {})')? I would like to learn more about this issue, therefore I would like to study these plug-ins. I would suspect that transferring the whole global namespace (g:) of Vim is unnecessary in most situations, but I might be wrong. Only transferring parts of it would avoid this problem, but maybe some plug-ins actually depend on doing this.

WolfgangMehner commented 7 years ago

This should be addressed by this branch: https://github.com/WolfgangMehner/vim-plugins/tree/template-dev I'll merge it into the master at some point.

WolfgangMehner commented 7 years ago

The fix is now also included in the main branch.