[issue6266] cElementTree.iterparse & ElementTree.iterparse return differently encoded strings
Fredrik Lundh
report at bugs.python.org
Sun Jun 21 02:15:38 CEST 2009
Fredrik Lundh <fredrik at effbot.org> added the comment:
Converting from UTF-8 to Unicode is the right thing to do, but
converting back to Latin-1 is not correct -- note that ET returns a
Unicode string, not an 8-bit string. There's a "makestring" helper that
does the right thing in the library; just changing:
parcel = Py_BuildValue("ss", (prefix) ? prefix : "", uri);
to
parcel = Py_BuildValue("sN", (prefix) ? prefix : "", makestring(uri));
should work (even if you should probably do that in two steps, and look
for errors from makestring before proceeding).
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6266>
_______________________________________
More information about the Python-bugs-list
mailing list