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 Frank, eli.bendersky, ezio.melotti, serhiy.storchaka
Date 2013-01-10.08:21:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1357806067.79.0.352083513309.issue16913@psf.upfronthosting.co.za>
In-reply-to
Content
I found such example. It happens when the data contains XML entity.

>>> ET.tostring(ET.XML('<root>a&amp;</root>'), method='text', encoding='unicode')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serhiy/py/cpython/Lib/xml/etree/ElementTree.py", line 1171, in tostring
    ElementTree(element).write(stream, encoding, method=method)
  File "/home/serhiy/py/cpython/Lib/xml/etree/ElementTree.py", line 824, in write
    _serialize_text(write, self._root)
  File "/home/serhiy/py/cpython/Lib/xml/etree/ElementTree.py", line 1057, in _serialize_text
    write(part)
TypeError: string argument expected, got 'list'


Indeed, itertext() returns a list of lists instead of list of strings.

>>> list(ET.XML('<root>a&amp;</root>').itertext())
[['a', '&']]

The bug is in the C implementation of itertext().
History
Date User Action Args
2013-01-10 08:21:07serhiy.storchakasetrecipients: + serhiy.storchaka, ezio.melotti, eli.bendersky, Frank
2013-01-10 08:21:07serhiy.storchakasetmessageid: <1357806067.79.0.352083513309.issue16913@psf.upfronthosting.co.za>
2013-01-10 08:21:07serhiy.storchakalinkissue16913 messages
2013-01-10 08:21:07serhiy.storchakacreate