<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">On Tue, 19 Mar 2019 at 23:13, David Mertz <<a href="mailto:mertz@gnosis.cx">mertz@gnosis.cx</a>> wrote:<br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div dir="auto"><div class="gmail_default" style="font-size:small"></div></div><div dir="auto">In a way, this case makes bugs worse because they are not only a Python internal matter. XML is used to communicate among many tools and programming languages, and relying on assumptions those other tools will not follow us a bad habit.</div></div></blockquote><div><br></div><div class="gmail_default" style="font-size:small">I have a recent example I encountered where the 3.7 behaviour (sorting attributes) results in a third-party tool behaving incorrectly, whereas maintaining attribute order works correctly. The particular case was using HTML <meta> tags for importing into Calibre for converting to an ebook. The most common symptom was that series indexes were sometimes being correctly imported, and sometimes not. Occasionally other <meta> tags would also fail to be correctly imported.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Turns out that <meta name="series_index" content="3"/> gave consistently correct results, whilst <meta content="3" name="series_index"/> was erratic. And whilst I'd specified the <meta> tags with the name attribute first, I was then passing the HTML through BeautifulSoup, which sorted the attributes.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Now Calibre is definitely in the wrong here - it should be able to import regardless of the order of attributes. But the fact is that there are a lot of tools out there that are semi-broken in a similar manner.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">This to me is an argument to default to maintaining order, but provide a way for the caller to control the order of attributes when formatting e.g. pass an ordering function. If you want sorted attributes, pass the built-in sorted function as your ordering function. But I think that's getting beyond the scope of this discussion.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Tim Delaney</div></div></div>