This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author scoder
Recipients Mariatta, dfrojas, eli.bendersky, matrixise, nedbat, rhettinger, scoder, serhiy.storchaka, sivert, taleinat, vstinner
Date 2019-03-16.08:00:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1552723248.51.0.771059934392.issue34160@roundup.psfhosted.org>
In-reply-to
Content
FWIW, I second Raymond's opposition against a new option. It's really not something that users should care about. Instead of us providing a new "sort or not" option, and people adding it (conditionally!) to their code to "fix" previous or future behaviour of the tool, they should better invest the time into fixing their code to not rely on behaviour that was never guaranteed.

Also, lxml cannot support such a serialisation option because it preserves the order of attributes as soon as they are *created*. It previously also sorted dicts on input, but only dicts and not other (sequential) ways to set attributes, which I always considered a necessary quirk to gain reproducible output. I'm planning to remove the sorting for Py3.6+ in the next release. It is better to leave the decision about attribute order entirely to the users.

It's not difficult to get sorted dict behaviour in Py3.6+ if you really want it (walk the tree and sort each el.attrib if you feel like it), but it's currently impossible to _not_ get sorted attributes but the "expected" order of creation. That's what we should fix.
History
Date User Action Args
2019-03-16 08:00:48scodersetrecipients: + scoder, rhettinger, vstinner, taleinat, nedbat, eli.bendersky, serhiy.storchaka, matrixise, sivert, Mariatta, dfrojas
2019-03-16 08:00:48scodersetmessageid: <1552723248.51.0.771059934392.issue34160@roundup.psfhosted.org>
2019-03-16 08:00:48scoderlinkissue34160 messages
2019-03-16 08:00:48scodercreate