[issue6266] cElementTree.iterparse & ElementTree.iterparse return differently encoded strings

Neil Muller report at bugs.python.org
Thu Jun 11 12:53:52 CEST 2009


New submission from Neil Muller <drnlmuller+bugs at gmail.com>:

Consider:

>>> from StringIO import StringIO
>>> source = StringIO('<body xmlns="http://&#233;ffbot.org/ns">text</body>')
>>> import xml.etree.ElementTree as ET
>>> events = ("start-ns",)
>>> context = ET.iterparse(source, events)
>>> for action, elem in context:
...    print action, elem
... 
start-ns ('', u'http://\xe9ffbot.org/ns')
>>> source.seek(0)
>>> import xml.etree.cElementTree as cET
>>> context = cET.iterparse(source, events)
>>> for action, elem in context:
...    print action, elem
... 
start-ns ('', 'http://\xc3\xa9ffbot.org/ns')

I'm not sure which is more correct here, but unsing different encodings
in the result is somewhat unexpected.

----------
messages: 89248
nosy: Neil Muller, effbot, jerith
severity: normal
status: open
title: cElementTree.iterparse & ElementTree.iterparse return differently encoded strings
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6266>
_______________________________________


More information about the Python-bugs-list mailing list