Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd7eea0f

Browse files
gh-96175: add missing self._localName assignment inxml.dom.minidom.Attr (GH-96176)
X-Ref:https://github.com/python/typeshed/pull/8590GH-discussion_r951473977Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>(cherry picked from commit58f6953)Co-authored-by: Kevin Kirsche <Kev.Kirsche+GitHub@gmail.com>
1 parent0aed1e7 commitd7eea0f

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

‎Lib/test/test_minidom.py‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
importpyexpat
1010
importxml.dom.minidom
1111

12-
fromxml.dom.minidomimportparse,Node,Document,parseString
12+
fromxml.dom.minidomimportparse,Attr,Node,Document,parseString
1313
fromxml.dom.minidomimportgetDOMImplementation
1414
fromxml.parsers.expatimportExpatError
1515

@@ -77,6 +77,20 @@ def testParseFromTextFile(self):
7777
dom.unlink()
7878
self.confirm(isinstance(dom,Document))
7979

80+
deftestAttrModeSetsParamsAsAttrs(self):
81+
attr=Attr("qName","namespaceURI","localName","prefix")
82+
self.assertEqual(attr.name,"qName")
83+
self.assertEqual(attr.namespaceURI,"namespaceURI")
84+
self.assertEqual(attr.prefix,"prefix")
85+
self.assertEqual(attr.localName,"localName")
86+
87+
deftestAttrModeSetsNonOptionalAttrs(self):
88+
attr=Attr("qName","namespaceURI",None,"prefix")
89+
self.assertEqual(attr.name,"qName")
90+
self.assertEqual(attr.namespaceURI,"namespaceURI")
91+
self.assertEqual(attr.prefix,"prefix")
92+
self.assertEqual(attr.localName,attr.name)
93+
8094
deftestGetElementsByTagName(self):
8195
dom=parse(tstfile)
8296
self.confirm(dom.getElementsByTagName("LI")== \

‎Lib/xml/dom/minidom.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ def __init__(self, qName, namespaceURI=EMPTY_NAMESPACE, localName=None,
358358
self._name=qName
359359
self.namespaceURI=namespaceURI
360360
self._prefix=prefix
361+
iflocalNameisnotNone:
362+
self._localName=localName
361363
self.childNodes=NodeList()
362364

363365
# Add the single child node that represents the value of the attr
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix unused ``localName`` parameter in the ``Attr`` class in:mod:`xml.dom.minidom`.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp