Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Lib/test/test_minidom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions Lib/xml/dom/minidom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Loading