Bug#638375: vim-gtk: can't print non-ASCII strings via Python: UnicodeDecodeError: 'ascii' codec can't decode byte

James Vega jamessan at debian.org
Sat Aug 20 13:19:34 UTC 2011


tag 638375 confirmed
thanks

On Thu, Aug 18, 2011 at 11:53:23PM +0200, Jakub Wilk wrote:
> I cannot print non-ASCII strings via Python anymore (it used to work
> at least until 2:7.3.154+hg~74503f6ee649-2+b1):

This was introduced by 7.3.220[0], which was intended to improve the
situation with encoding and the Vim/Python interface.

> $ locale charmap
> UTF-8
> 
> $ vim -u NONE -U NONE -N -c "python print '\xc3\xb3'"
> Error detected while processing command line:
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)

The problematic changes seem to be line 71

-    if (!PyArg_ParseTuple(args, "s#", &str, &len))
+    if (!PyArg_ParseTuple(args, "es#", p_enc, &str, &len))

and line 120

-       if (!PyArg_Parse(line, "s#", &str, &len)) {
+       if (!PyArg_Parse(line, "es#", p_enc, &str, &len)) {

Changing the second argument to "et#"[1] instead seems to fix the
current issue, but I'm not sure yet how that affects the original issue.
I'll have to take a deeper look at it later.

[0]: http://ftp.vim.org/pub/vim/patches/7.3/7.3.220
[1]: http://docs.python.org/c-api/arg.html
-- 
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega <jamessan at debian.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-vim-maintainers/attachments/20110820/e4f46491/attachment.pgp>


More information about the pkg-vim-maintainers mailing list