[issue21403] cElementTree node creation with attributes is bugged
Santoso Wijaya
report at bugs.python.org
Wed Apr 30 22:58:00 CEST 2014
New submission from Santoso Wijaya:
Observe:
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import xml.etree.ElementTree as ET
>>> root = ET.Element('root', attrib={'Name':'Root'})
>>> child = ET.SubElement(root, 'child', attrib={'Name':'Child'})
>>> ET.tostring(root)
'<root Name="Root"><child Name="Child" /></root>'
>>> import xml.etree.cElementTree as cET
>>> root = cET.Element('root', attrib={'Name':'Root'})
>>> child = cET.SubElement(root, 'child', attrib={'Name':'Child'})
>>> cET.tostring(root)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1126, in tostring
ElementTree(element).write(file, encoding, method=method)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 820, in write
serialize(write, self._root, encoding, qnames, namespaces)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 932, in _serialize_xml
v = _escape_attrib(v, encoding)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1092, in _escape_attrib
_raise_serialization_error(text)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1052, in _raise_serialization_error
"cannot serialize %r (type %s)" % (text, type(text).__name__)
TypeError: cannot serialize {'Name': 'Root'} (type dict)
----------
components: Library (Lib)
messages: 217652
nosy: santa4nt
priority: normal
severity: normal
status: open
title: cElementTree node creation with attributes is bugged
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21403>
_______________________________________
More information about the Python-bugs-list
mailing list