[Python-checkins] cpython (3.4): Issue #21774: Fix incorrect variable in xml.dom.minidom

raymond.hettinger python-checkins at python.org
Sun Jun 15 23:50:47 CEST 2014


http://hg.python.org/cpython/rev/ca33faa214ab
changeset:   91187:ca33faa214ab
branch:      3.4
parent:      91182:601a08fcb507
user:        Raymond Hettinger <python at rcn.com>
date:        Sun Jun 15 14:48:19 2014 -0700
summary:
  Issue #21774: Fix incorrect variable in xml.dom.minidom

files:
  Lib/test/test_minidom.py |  7 +++++++
  Lib/xml/dom/minidom.py   |  2 +-
  Misc/NEWS                |  4 ++++
  3 files changed, 12 insertions(+), 1 deletions(-)


diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py
--- a/Lib/test/test_minidom.py
+++ b/Lib/test/test_minidom.py
@@ -1531,6 +1531,13 @@
         num_children_after = len(doc.childNodes)
         self.assertTrue(num_children_after == num_children_before - 1)
 
+    def testProcessingInstructionNameError(self):
+        # wrong variable in .nodeValue property will
+        # lead to "NameError: name 'data' is not defined"
+        doc = parse(tstfile)
+        pi = doc.createProcessingInstruction("y", "z")
+        pi.nodeValue = "crash"
+
 def test_main():
     run_unittest(MinidomTest)
 
diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py
--- a/Lib/xml/dom/minidom.py
+++ b/Lib/xml/dom/minidom.py
@@ -976,7 +976,7 @@
     def _get_nodeValue(self):
         return self.data
     def _set_nodeValue(self, value):
-        self.data = data
+        self.data = value
     nodeValue = property(_get_nodeValue, _set_nodeValue)
 
     # nodeName is an alias for target
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -26,6 +26,10 @@
   run_forever() and run_until_complete() methods of asyncio.BaseEventLoop now
   raise an exception if the event loop was closed.
 
+- Issue #21774: Fixed NameError for an incorrect variable reference in the
+  XML Minidom code for creating processing instructions.
+  (Found and fixed by Claudiu Popa.)
+
 - Issue #21766: Prevent a security hole in CGIHTTPServer by URL unquoting paths
   before checking for a CGI script at that path.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list