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 serhiy.storchaka
Recipients BreamoreBoy, doerwalter, georg.brandl, ngrig, serhiy.storchaka
Date 2012-05-30.07:57:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1338364658.4.0.563015738773.issue1470548@psf.upfronthosting.co.za>
In-reply-to
Content
Oh, I see XMLGenerator completely outdated. It even has not been ported to Python 3. See function _write:

    def _write(self, text):
        if isinstance(text, str):
            self._out.write(text)
        else:
            self._out.write(text.encode(self._encoding, _error_handling))

In Python 2 there was a choice between bytes and unicode strings. But in Python 3 encoding never happens.

XMLGenerator does not distinguish between binary and text streams.

Here is a patch that fixes the work of XMLGenerator in Python 3. Unfortunately, it is impossible to avoid the loss of backward compatibility. I tried to keep the code to work for the most common cases, but some code which "worked" before may break (including I had to correct some tests).
History
Date User Action Args
2012-05-30 07:57:38serhiy.storchakasetrecipients: + serhiy.storchaka, doerwalter, georg.brandl, ngrig, BreamoreBoy
2012-05-30 07:57:38serhiy.storchakasetmessageid: <1338364658.4.0.563015738773.issue1470548@psf.upfronthosting.co.za>
2012-05-30 07:57:37serhiy.storchakalinkissue1470548 messages
2012-05-30 07:57:37serhiy.storchakacreate