[XML-SIG] printing Unicode xml to StringIO

M.-A. Lemburg mal@lemburg.com
Fri, 28 Dec 2001 09:57:42 +0100


"Martin v. Loewis" wrote:
> 
> > What is going wrong here?  According to the manual, StringIO should be able
> > to handle utf-8 strings...
> 
> That's a bug in Python, introduced with rev 1.19 of StringIO.py, as
> part of patch #462596. Please submit a bug report on SF.

Actually, I think that this is a bug in the documentation, not the
code. StringIO and cStringIO were never meant to work on anything but
strings and memory buffers. 

The note that Fred added to the docs about
StringIO's capability of storing Unicode in it's buffer list is
simply an artifact of the implementation.

Please use the .encode() method on Unicode objects before writing
them to a StringIO object.

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Company & Consulting:                           http://www.egenix.com/
Python Software:                   http://www.egenix.com/files/python/