[Python-Dev] [Python-3000] New proposition for Python3 bytes filename issue

Victor Stinner victor.stinner at haypocalc.com
Wed Oct 1 10:43:25 CEST 2008


Le Wednesday 01 October 2008 04:06:25 glyph at divmod.com, vous avez écrit :
>     b = gtk.Button(u"\u0000/hello/world")
>
> which emits this message:
>     TypeError: OGtkButton.__init__() argument 1 must be string without
> null bytes or None, not unicode
>
> SQLite has a similar problem with NULLs, and I'm definitely sticking
> paths in there, too.

I think that you can say "all C libraries".

Would it possible to convert the encoded string to bytes just before call Gtk? 
(job done by some Python internals, not as an explicit conversion)

I don't know if it would help the discussion, but Java uses its own modified 
UTF-8 encoding:
 * NUL byte is encoded as 0xc0 0x80 instead of 0x00
 * Java doesn't support unicode > 0xFFFF (bouuuuh!)
http://java.sun.com/javase/6/docs/api/java/io/DataInput.html#modified-utf-8

-- 
Victor Stinner aka haypo
http://www.haypocalc.com/blog/


More information about the Python-Dev mailing list