Skip to content

gh-100710: Add nodeValue default to xml.dom.minidom.Node base class - #155586

Open
SomSamantray wants to merge 2 commits into
python:mainfrom
SomSamantray:gh-100710-minidom-nodevalue
Open

gh-100710: Add nodeValue default to xml.dom.minidom.Node base class#155586
SomSamantray wants to merge 2 commits into
python:mainfrom
SomSamantray:gh-100710-minidom-nodevalue

Conversation

@SomSamantray

Copy link
Copy Markdown

Fixes gh-100710.

Node.nodeValue is documented per the DOM interface it implements, but the base Node class in Lib/xml/dom/minidom.py never declares it — only concrete subclasses (Element, DocumentFragment, DocumentType, Entity, Notation, Document as a class attribute; Attr, ProcessingInstruction, CharacterData via a property) set it.

At runtime this is harmless since every instantiable subclass already sets nodeValue. The reported symptom is static analysis: code holding a Node-typed reference (e.g. iterating childNodes typed as Node) and accessing .nodeValue triggers a false-positive "unknown member" error from type checkers like Pylance, because the attribute isn't declared on the base class.

Fix

Add nodeValue = None as a class-level default on Node, matching the existing pattern already used for namespaceURI, parentNode, ownerDocument, nextSibling, and previousSibling.

Testing

  • Added testNodeValueDefaultOnBaseNode in Lib/test/test_minidom.py, asserting the base Node class (and a bare Node() instance) exposes nodeValue as None.
  • Ran the full test_minidom suite locally (132 tests, all passing).

…lass

Node.nodeValue is documented per the DOM interface but was never
declared on the base Node class in Lib/xml/dom/minidom.py, only on
its concrete subclasses. At runtime this was harmless (every
subclass already sets it), but static type checkers such as
Pylance flag `.nodeValue` access on Node-typed references as an
unknown member.

Add nodeValue = None as a class-level default on Node, matching the
existing pattern for namespaceURI/parentNode/etc.
@python-cla-bot

python-cla-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@SomSamantray

Copy link
Copy Markdown
Author

@python-cla-bot check

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.

[xml.dom.minidom] nodeValue attr is not defined on Node class but directly on all derived classes

1 participant