You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
xml.dom.minidom.Document.getElementById() result for duplicate IDs depends on earlier lookups #161110
When several elements have the same ID, xml.dom.minidom.Document.getElementById() first returns the last of the siblings, and a later lookup of a different ID, which continues the incremental search, overwrites the cached entry. The same call can then return a different element on an unmodified document.
fromxml.domimportminidomdoc=minidom.parseString(
'<!DOCTYPE r [<!ATTLIST e id ID #IMPLIED>]>''<r><e id="a" n="1"/><e id="a" n="2"/></r>')
print(doc.getElementById("a").getAttribute("n")) # 2doc.getElementById("b") # Noneprint(doc.getElementById("a").getAttribute("n")) # 1
Both calls should return the same element, the first one in document order (as the WHATWG DOM and libxml2 do).
Activity
gh-161110: Make minidom getElementById() stable for duplicate IDs (GH…