New submission from Steve Dower <steve.do...@python.org>:

I suspect this is related to the fix for issue30485, 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.

----------
components: XML
keywords: 3.7regression
messages: 341721
nosy: eli.bendersky, lukasz.langa, scoder, steve.dower
priority: normal
severity: normal
stage: needs patch
status: open
title: ElementTree.find attribute matching with empty namespace
type: behavior
versions: Python 3.8

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

Reply via email to