[New-bugs-announce] [issue16913] ElementTree tostring error when method='text'
Frank
report at bugs.python.org
Thu Jan 10 06:20:09 CET 2013
New submission from Frank:
Since upgrading to python 3.3 the tostring method fails when the output method is requested as text. Code like this:
with open(fp, mode='rt') as f:
data = f.read()
tree, idmap = ET.XMLID(data)
print(ET.tostring(tree, method='text', encoding='unicode'))
Generates the following error:
Traceback (most recent call last):
File "/home/john/Desktop/docs/Pear/pear.py", line 64, in pass_four
print(ET.tostring(tree, method='text', encoding='unicode'))
File "/usr/lib/python3.3/xml/etree/ElementTree.py", line 1171, in tostring
ElementTree(element).write(stream, encoding, method=method)
File "/usr/lib/python3.3/xml/etree/ElementTree.py", line 824, in write
_serialize_text(write, self._root)
File "/usr/lib/python3.3/xml/etree/ElementTree.py", line 1057, in _serialize_text
write(part)
TypeError: string argument expected, got 'list'
Whereas it used to return plain text with formatting tags stripped from the root element on prior versions of python.
----------
components: XML
messages: 179523
nosy: Frank
priority: normal
severity: normal
status: open
title: ElementTree tostring error when method='text'
versions: Python 3.3
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16913>
_______________________________________
More information about the New-bugs-announce
mailing list