Visitar URL original
gh-158978: Fix cloning of DOM Level 1 nodes in xml.dom.minidom by sricursion · Pull Request #158987 · python/cpython · GitHub
Skip to content

gh-158978: Fix cloning of DOM Level 1 nodes in xml.dom.minidom - #158987

Open
sricursion wants to merge 1 commit into
python:mainfrom
sricursion:minidom-clone-dom1-names
Open

sricursion wants to merge 1 commit into
python:mainfrom
sricursion:minidom-clone-dom1-names

Conversation

@sricursion

@sricursion sricursion commented Oct 7, 2026 •

Copy link
Copy Markdown

Node.cloneNode() and Document.importNode() raise NamespaceErr for DOM Level 1 nodes that have a colon in the name, for example createElement("svg:rect"), setAttribute("xmlns:xsi", ...), createAttribute("a:b"), or any node of a document parsed with namespaces disabled. _clone_node() rebuilt every element and attribute with createElementNS(), setAttributeNS() and createAttributeNS(), and since gh-156665 those reject a prefixed name in no namespace. The same applies to setAttribute("xmlns", ...), which is rejected as the xmlns attribute in the wrong namespace. This is a regression on the main branch only; 3.15 and earlier clone these nodes without error. The clones are now created directly with Element and Attr, the way the factory methods did before validation was added, so the clones of namespaced nodes are unchanged.

There is no NEWS entry, since gh-156665 is not in any release yet.

cloneNode() and importNode() created the clones with createElementNS(),
setAttributeNS() and createAttributeNS(), which now reject a prefixed
name in no namespace. Create the Element and Attr nodes directly
instead.
@python-cla-bot

python-cla-bot Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app

bedevere-app Bot commented Oct 7, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant