New submission from bagrat lazaryan:

xml.etree.ElementTree.ElementTree.write method (and, as a derivative, 
xml.etree.ElementTree.tostring function) sorts attributes in lexical order. 
while an admissible behavior instead of the randomness inherited from ordinary 
dict, this prevents a picky user to have her own custom ordering by passing an 
OrderedDict to Element, SubElement and the like (i guess there are none). that 
is to say:

if
-----------------------------------
e = Element("tag", OrderedDict([("a", "a"), ("c", "c"), ("b", "b")]))
-----------------------------------
then both
-----------------------------------
tostring(e)
ElementTree(e).write("xml.xml")
-----------------------------------
will result in
-----------------------------------
<tag a="a" b="b" c="c" />
-----------------------------------
while the intention of the user was
-----------------------------------
<tag a="a" c="c" b="b" />

----------
components: Library (Lib)
messages: 207721
nosy: bagratte
priority: normal
severity: normal
status: open
title: xml.etree.ElementTree.ElementTree.write attribute sorting
type: enhancement
versions: Python 3.3

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue20198>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to