[issue20198] xml.etree.ElementTree.ElementTree.write attribute sorting

Stefan Behnel report at bugs.python.org
Thu Jan 9 08:50:21 CET 2014


Stefan Behnel added the comment:

IMHO, it makes sense to support this. My intuition tells me that lxml also handles this as expected, by accident through iteration.

Not sure how to do this correctly in ET, though. Special case dict? Or special case OrderedDict? Both would leave some reasonable use cases uncovered, e.g. dict subclasses that do not impact iteration, and self-implemented OrderedDict-like types. And being too broad in the special casing will certainly kill someone's doctests somewhere...

Given that OrderedDict is the one way to do this in recent Python versions, I guess it would be reasonable to special case on that type.

----------
nosy: +eli.bendersky, scoder

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


More information about the Python-bugs-list mailing list