Message161933
| 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). |
|