Skip to content

gh-96175: add missing self._localName assignment in xml.dom.minidom.Attr #96176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 23, 2022
Merged
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
16 changes: 15 additions & 1 deletion Lib/test/test_minidom.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pyexpat
import xml.dom.minidom

from xml.dom.minidom import parse, Node, Document, parseString
from xml.dom.minidom import parse, Attr, Node, Document, parseString
from xml.dom.minidom import getDOMImplementation
from xml.parsers.expat import ExpatError

Expand Down Expand Up @@ -77,6 +77,20 @@ def testParseFromTextFile(self):
dom.unlink()
self.confirm(isinstance(dom, Document))

def testAttrModeSetsParamsAsAttrs(self):
attr = Attr("qName", "namespaceURI", "localName", "prefix")
self.assertEqual(attr.name, "qName")
self.assertEqual(attr.namespaceURI, "namespaceURI")
self.assertEqual(attr.prefix, "prefix")
self.assertEqual(attr.localName, "localName")

def testAttrModeSetsNonOptionalAttrs(self):
attr = Attr("qName", "namespaceURI", None, "prefix")
self.assertEqual(attr.name, "qName")
self.assertEqual(attr.namespaceURI, "namespaceURI")
self.assertEqual(attr.prefix, "prefix")
self.assertEqual(attr.localName, attr.name)

def testGetElementsByTagName(self):
dom = parse(tstfile)
self.confirm(dom.getElementsByTagName("LI") == \
Expand Down
2 changes: 2 additions & 0 deletions Lib/xml/dom/minidom.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ def __init__(self, qName, namespaceURI=EMPTY_NAMESPACE, localName=None,
self._name = qName
self.namespaceURI = namespaceURI
self._prefix = prefix
if localName is not None:
self._localName = localName
self.childNodes = NodeList()

# Add the single child node that represents the value of the attr
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix unused ``localName`` parameter in the ``Attr`` class in :mod:`xml.dom.minidom`.