STINNER Victor <vstin...@redhat.com> added the comment:

Please don't break the backward compatibility without an easy way to retrieve 
Python 3.7 behavior.

I set the priority to release blocker until a consensus can be found, and I add 
Lukasz (Python 3.8 release manager) in the loop.


Ned Batchelder: "I'm a bit mystified why people are still opposed to providing 
sorting control, even after people are resorting to "hack work-arounds."  The 
(two) pull requests that provide the control are simple, easy to understand, 
and easy to test."

I concur. I'm fine with sorting by default, but it breaks the backward 
compatibility on purpose without providing an option to opt-in for the old 
behavior :-(

Many XML parsers rely on the order of attributes. It's part of the XML 
"semantics". Well, it shouldn't, but I cannot fix all applications around the 
world to explain them that Python is right, and they are all wrong :-)

It's not straighforward to fix an application to get Python 3.7 behavior. I 
would prefer to not have to copy-paste Stefan Behnel's recipe in every project 
using XML who wants to sort attributes:

"""
Something like this:

def sort_attributes(root):
    for el in root.iter():
        attrib = el.attrib
        if len(attrib) > 1:
            attribs = sorted(attrib.items())
            attrib.clear()
            attrib.update(attribs)
"""

This recipe does modify the document and so changes the behavior of the 
application when it iterates on attributes later, whereas in Python 3.7 
attributes are only sorted while writing the XML into a file.

----------
nosy: +lukasz.langa
priority: normal -> release blocker

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

Reply via email to