Message179523
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. |
|
Date |
User |
Action |
Args |
2013-01-10 05:20:09 | Frank | set | recipients:
+ Frank |
2013-01-10 05:20:09 | Frank | set | messageid: <1357795209.81.0.959594987478.issue16913@psf.upfronthosting.co.za> |
2013-01-10 05:20:09 | Frank | link | issue16913 messages |
2013-01-10 05:20:08 | Frank | create | |
|