[issue21403] cElementTree's Element creation handles attrib argument different from ET

Santoso Wijaya report at bugs.python.org
Thu May 1 17:43:40 CEST 2014


Santoso Wijaya added the comment:

There is still a matter of inconsistency between the two implementations and between 2.7 and 3.x. IMO, the Python-based ElementTree implementation is more graceful at handling the "attrib" argument.

The signature of the factory function Element (and SubElement) in the doc is thus:

    class xml.etree.ElementTree.Element(tag, attrib={}, **extra)


which is fair game for the user to use "attrib" as a keyword argument.

Further, this serialization (in 3.x) does not really make sense, anyway:

>>> cET.tostring(root)
b'<root attrib="{\'Name\': \'Root\'}"><child attrib="{\'Name\': \'Child\'}" /></root>'

----------
components: +XML

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21403>
_______________________________________


More information about the Python-bugs-list mailing list