summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_minidom.py16
-rw-r--r--Lib/xml/dom/minidom.py2
-rw-r--r--Misc/NEWS.d/next/Library/2022-08-22-13-54-20.gh-issue-96175.bH7zGU.rst1
3 files changed, 18 insertions, 1 deletions
diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py
index 9762025..ef38c36 100644
--- a/Lib/test/test_minidom.py
+++ b/Lib/test/test_minidom.py
@@ -9,7 +9,7 @@ import unittest
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
@@ -77,6 +77,20 @@ class MinidomTest(unittest.TestCase):
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") == \
diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py
index d09ef5e..ef8a159 100644
--- a/Lib/xml/dom/minidom.py
+++ b/Lib/xml/dom/minidom.py
@@ -358,6 +358,8 @@ class Attr(Node):
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
diff --git a/Misc/NEWS.d/next/Library/2022-08-22-13-54-20.gh-issue-96175.bH7zGU.rst b/Misc/NEWS.d/next/Library/2022-08-22-13-54-20.gh-issue-96175.bH7zGU.rst
new file mode 100644
index 0000000..c34eff2
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-08-22-13-54-20.gh-issue-96175.bH7zGU.rst
@@ -0,0 +1 @@
+Fix unused ``localName`` parameter in the ``Attr`` class in :mod:`xml.dom.minidom`.