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

2020-09-07 Thread Stefan Behnel


Change by Stefan Behnel :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2018-11-11 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

dictionary's insertion order is preserved in 3.6 and above. Hence sorting by 
lexical order was removed in issue34160 and there is a discussion in the same 
issue to add an option to provide sorted output.

As part of triaging I propose closing this issue since the changes were made in 
issue34160.

$ ./python.exe
Python 3.8.0a0 (heads/master:cd449806fa, Nov 12 2018, 09:51:24)
[Clang 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from xml.etree.ElementTree import Element, tostring
>>> from collections import OrderedDict
>>> e = Element("tag", OrderedDict([("a", "a"), ("c", "c"), ("b", "b")]))
>>> tostring(e)
b''
>>> e = Element("tag", dict([("a", "a"), ("c", "c"), ("b", "b")]))
>>> tostring(e)
b''

--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2014-04-17 Thread Martin Panter

Changes by Martin Panter vadmium...@gmail.com:


--
nosy: +vadmium

___
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



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

2014-04-02 Thread bagrat lazaryan

bagrat lazaryan added the comment:

well... ElementTree.py imports some c accelerators as can be seen at the end of 
the file. i have no idea how to get to those accelerators, and even if i had, i 
don't think i would make anything of them.
as far as the pure python code concerns in the rest of ElementTree.py, it 
suffices not to sort the items in _serialize_xml:

line 929 of ElementTree.py:
-for k, v in sorted(items):  # lexical order
+for k, v in items:

i gather something similar must be done in c accelerators.

(by the way, does anyone know why i am not receiving email notifications when 
someone posts to an issue i have started or i have commented to?)

--

___
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



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

2014-04-02 Thread bagrat lazaryan

Changes by bagrat lazaryan bagra...@live.com:


--
versions: +Python 3.4

___
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



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

2014-01-08 Thread bagrat lazaryan

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



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

2014-01-08 Thread Stefan Behnel

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 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



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

2014-01-08 Thread Stefan Behnel

Stefan Behnel added the comment:

 My intuition tells me that lxml also handles this as expected, by accident 
 through iteration.

And, obviously, it doesn't. It sorts, too. :)

I'm ok with switching for both libraries.

--

___
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