[issue34160] ElementTree not preserving attribute order
Serhiy Storchaka
report at bugs.python.org
Fri Jul 20 00:46:12 EDT 2018
Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:
Attributes are sorted by name when converted an element to the text representation for making it stable. Changing this may break existing software.
I think it makes sense now to add an optional keyword-only parameter sort_attrs (True by default) for functions tostring() and tostringlist() and method ElementTree.write(). If it is False, attributes will keep the original order.
Since dump() is used for debugging only, it could change the behavior by default, even in maintained releases. But currently it just uses ElementTree.write(), which should sort attributes by default for compatibility.
----------
nosy: +serhiy.storchaka
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34160>
_______________________________________
More information about the Python-bugs-list
mailing list