This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mlh
Recipients
Date 2004-04-19.17:18:47
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
When XMLGenerator is supplied with an encoding such as
'utf-8' and subsequently with some non-ASCII Unicode
characters, it crashes, because of its characters()
method. The current version is:

def characters(self, content):
    self._out.write(escape(content))

This completely ignores the encoding, and will (when
writing to something such as a StringIO or the like)
simply try to convert this into an ASCII string. The
encoding is only used in the XML header, not as the
real encoding!

It may be that I've gotten things wrong, but I would
suggest the following fix:

def characters(self, content):
    self._out.write(escape(content).encode(self._encoding))

This seems to work well for me, at least.
History
Date User Action Args
2007-08-23 14:21:06adminlinkissue938076 messages
2007-08-23 14:21:06admincreate