[issue34160] ElementTree not preserving attribute order

Raymond Hettinger report at bugs.python.org
Sat Nov 10 11:05:07 EST 2018


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

> I'm checking that my XML generating code is producing the right XML.

ISTM that the coverage tests as currently written aren't good tests.  Why not update the tests to check the generated XML is what the code asked it to generate?  Otherwise, the tests are relying on a non-guaranteed implementation detail. 

Alternatively, use c14n.Canonicalize[1] which implements standard compliant cross-language canonicalization (as opposed to non-guaranteed ad-hoc comparison which just happens to work).

[1] https://www.ibm.com/developerworks/xml/library/x-c14n/

Note with attribute order preservation, code now has the ability to produce exactly the XML it wants to produce.  The explicit intention of the user is honored.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34160>
_______________________________________


More information about the Python-bugs-list mailing list