diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index 46249e5138aed52..ce7c05335af801a 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -64,6 +64,15 @@ def testDocumentAsyncAttr(self): self.assertFalse(doc.async_) self.assertFalse(Document.async_) + def testNodeValueDefaultOnBaseNode(self): + # gh-100710: nodeValue must be declared on the base Node class + # (not just on its subclasses) so that generic Node-typed code + # and static type checkers see the attribute. + self.assertIsNone(Node.nodeValue) + node = Node() + self.assertTrue(hasattr(node, 'nodeValue')) + self.assertIsNone(node.nodeValue) + def testParseFromBinaryFile(self): with open(tstfile, 'rb') as file: dom = parse(file) diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py index 16b33b90184dc59..330fd42d5c7fb82 100644 --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -37,6 +37,7 @@ class Node(xml.dom.Node): ownerDocument = None nextSibling = None previousSibling = None + nodeValue = None prefix = EMPTY_PREFIX # non-null only for NS elements and attributes diff --git a/Misc/NEWS.d/next/Library/2026-08-11-18-30-00.gh-issue-100710.6V5Prz.rst b/Misc/NEWS.d/next/Library/2026-08-11-18-30-00.gh-issue-100710.6V5Prz.rst new file mode 100644 index 000000000000000..87cab85525f40ad --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-08-11-18-30-00.gh-issue-100710.6V5Prz.rst @@ -0,0 +1,5 @@ +Add a class-level ``nodeValue`` default (``None``) to the base +:class:`!Node` class in :mod:`xml.dom.minidom`, matching the DOM +interface it implements. Every concrete subclass already sets +``nodeValue`` at runtime, so this only affects code and static type +checkers that reference a bare ``Node``-typed value.