Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 92a4055

Browse files
committed
Issue #21774: Fix incorrect variable in xml.dom.minidom
1 parent ef8abfc commit 92a4055

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

Lib/test/test_minidom.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,13 @@ def testDocRemoveChild(self):
15311531
num_children_after = len(doc.childNodes)
15321532
self.assertTrue(num_children_after == num_children_before - 1)
15331533

1534+
def testProcessingInstructionNameError(self):
1535+
# wrong variable in .nodeValue property will
1536+
# lead to "NameError: name 'data' is not defined"
1537+
doc = parse(tstfile)
1538+
pi = doc.createProcessingInstruction("y", "z")
1539+
pi.nodeValue = "crash"
1540+
15341541
def test_main():
15351542
run_unittest(MinidomTest)
15361543

Lib/xml/dom/minidom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ def __init__(self, target, data):
976976
def _get_nodeValue(self):
977977
return self.data
978978
def _set_nodeValue(self, value):
979-
self.data = data
979+
self.data = value
980980
nodeValue = property(_get_nodeValue, _set_nodeValue)
981981

982982
# nodeName is an alias for target

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ Library
2626
run_forever() and run_until_complete() methods of asyncio.BaseEventLoop now
2727
raise an exception if the event loop was closed.
2828

29+
- Issue #21774: Fixed NameError for an incorrect variable reference in the
30+
XML Minidom code for creating processing instructions.
31+
(Found and fixed by Claudiu Popa.)
32+
2933
- Issue #21766: Prevent a security hole in CGIHTTPServer by URL unquoting paths
3034
before checking for a CGI script at that path.
3135

0 commit comments

Comments
 (0)