[Python-Dev] Is XML serialization output guaranteed to be bytewise identical forever?

Victor Stinner vstinner at redhat.com
Wed Mar 20 21:07:01 EDT 2019


Le lun. 18 mars 2019 à 23:41, Raymond Hettinger
<raymond.hettinger at gmail.com> a écrit :
> The code in the current 3.8 alpha differs from 3.7 in that it removes attribute sorting and instead preserves the order the user specified when creating an element.  As far as I can tell, there is no objection to this as a feature.

By the way, what's the rationale of this backward incompatible change?

I found this short message:
"FWIW, this issue arose from an end-user problem. She had a hard
requirement to show a security clearance level as the first attribute.
We did find a work around but it was hack."
https://bugs.python.org/issue34160#msg338098

It's the first time that I hear an user asking to preserve attribute
insertion order (or did I miss a previous request?). Technically, it
was possible to implement the feature earlier using OrderedDict. So
why doing it now?

Is it really worth it to break Python backward compatibility (change
the default behavior) for everyone, if it's only needed for few users?


> 1) Revert back to the 3.7 behavior. This of course, makes all the test pass :-)  The downside is that it perpetuates the practice of bytewise equality tests and locks in all implementation quirks forever.  I don't know of anyone advocating this option, but it is the simplest thing to do.

Can't we revert Python 3.7 behavior and add a new opt-in option to
preserve the attribution insertion order (current Python 3.8 default
behavior)?

Python 3.7, sorting attributes by name, doesn't sound so silly to me.
It's one arbitrary choice, but at least the output is deterministic.
And well, Python is doing that for 20 years :-)


> 4) Fix the tests in the third-party modules (...)

I also like the option "not break the backward compatibility" to not
have to fix any project :-)

Victor
-- 
Night gathers, and now my watch begins. It shall not end until my death.


More information about the Python-Dev mailing list