Issue 36831: ElementTree.find attribute matching with empty namespace (original) (raw)

I suspect this is related to the fix for , but haven't fully debugged it.

In PC/layout/support/appxmanifest.py, I have code that looks up an existing element and adds it if missing:

def find_or_add(xml, element, attr=None, always_add=False): if always_add: e = None else: q = element if attr: q += "[@{}='{}']".format(*attr) e = xml.find(q, APPXMANIFEST_NS) if e is None: ... return e

For my 3.8.0a4 build, this started failing to match elements with attributes included. As a result, I ended up with N elements in a space where the schema only allows 1, and part of the 3.8.0a4 release is now blocked (okay, it's unblocked because I manually fixed a file and built the rest by hand, but it still held things up by a day).

I found that by removing the empty string entry in my namespaces dictionary the issue is fixed:

APPXMANIFEST_NS = { #"": "http://schemas.microsoft.com/appx/manifest/foundation/windows10", "m": "http://schemas.microsoft.com/appx/manifest/foundation/windows10", ... }

So I'm not exactly sure what's going on, but as code that worked fine in 3.8.0a3 and earlier now no longer works, I think we should see whether it was a deliberate break or accidental. If there's no reason to regress users, I'd prefer to avoid it.