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

> Victor, as much as I appreciate backwards compatibility, I really don't think 
> it's a big deal in this case.

In short, the XML serialization is no longer deterministic. It depends in which 
order attributes are defined. Example:
---
from xml.etree import ElementTree as ET

document = ET.Element('document')
document.attrib['a'] = '1'
document.attrib['b'] = '2'
ET.dump(document)

document = ET.Element('document')
document.attrib['b'] = '2'
document.attrib['a'] = '1'
ET.dump(document)
---

Python 3.7 output:
---
<document a="1" b="2" />
<document a="1" b="2" />
---

Python 3.8 output:
---
<document a="1" b="2" />
<document b="2" a="1" />
---

On this example, it's obvious that the attributes are defined in a different 
order, but the code which generates the XML document can be way more complex 
and use unordered data structures like set().

Why does it matter? Most programs compare XML using basic string comparison, 
they don't implement smart XML comparison which ignore attributes order.

Concrete example:

* A program which rewrites the XML on disk if attribute order changes (useless 
disk write).
* Version Control System (Git, hg, svn, whatever) sees the file as modified and 
produces a change which can be unexpected and annoy users (use more disk space, 
more network bandwidth, etc.)
* https://reproducible-builds.org/
* It breaks docutils unit tests which uses straightfoward assertEqual(). 
docutils is just one example: it's not hard to imagine many other applications 
using XML and which use a similar check.
* etc.

It's not just a matter of parsers.


> My (somewhat educated) gut feeling is that most users simply won't care or 
> won't even notice the change.

... Really? Why do you think that so many people are involved in this issue if 
nobody cares of XML attribute order? :-)

----------

_______________________________________
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