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.

classification
Title: startElementNS in xml.sax.saxutils.XMLGenerator ignored encoding
Type: behavior Stage: resolved
Components: XML Versions: Python 2.6
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, ezio.melotti, gromgull, serhiy.storchaka
Priority: normal Keywords:

Created on 2011-03-23 13:30 by gromgull, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
xmltest.py gromgull, 2011-03-25 10:34
Messages (4)
msg131863 - (view) Author: Gunnar Aastrand Grimnes (gromgull) Date: 2011-03-23 13:30
The startElementNS method in the XMLGenerator ignores the encoding set. 

it does: 

self._out.write(' xmlns:%s="%s"' % (prefix, uri))

whereas it should have done: 

self._write(' xmlns:%s="%s"' % (prefix, uri))

Issue 938076 was similar to this, but for a different method.
msg131879 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2011-03-23 14:45
Do you have a test or a small script which shows the incorrect output?
msg132077 - (view) Author: Gunnar Aastrand Grimnes (gromgull) Date: 2011-03-25 10:34
I came across the bug when trying to write XML documents to StringIO objects. This does not work, since the output contains a mix of unicode and str objects, and StringIO gets confused. 

A better alternative is to use io.BytesIO, since all output should be encoded, but this also throws an error since it gets some unicode objects. 

The attached file breaks for both cases (comment/uncomment StringIO to test)
msg182120 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-02-14 21:13
Already fixed in issue1470548.
History
Date User Action Args
2022-04-11 14:57:15adminsetgithub: 55858
2013-02-14 21:13:08serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg182120

resolution: out of date
stage: test needed -> resolved
2011-03-26 19:10:25ezio.melottisetnosy: + ezio.melotti
2011-03-25 10:34:28gromgullsetfiles: + xmltest.py

messages: + msg132077
2011-03-23 14:45:21amaury.forgeotdarcsetnosy: + amaury.forgeotdarc

messages: + msg131879
stage: test needed
2011-03-23 13:30:22gromgullcreate