Serhiy Storchaka added the comment:
I found such example. It happens when the data contains XML entity.
>>> ET.tostring(ET.XML('<root>a&</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&</root>').itertext())
[['a', '&']]
The bug is in the C implementation of itertext().
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue16913>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com