From: Andrew M. Kuchling Date: Sun, 25 Jul 2010 23:49:57 +0000 (+0000) Subject: Merged revisions 83152 via svnmerge from X-Git-Tag: v2.7.1rc1~557 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=53f94d07532024b49075ca03acda3e170e74859a;p=thirdparty%2FPython%2Fcpython.git Merged revisions 83152 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r83152 | andrew.kuchling | 2010-07-25 19:38:47 -0400 (Sun, 25 Jul 2010) | 1 line #777884: make .normalize() do nothing for childless nodes, instead of raising an exception ........ --- diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index 1f0b229fb26b..8fbc5786cd8b 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -945,6 +945,14 @@ class MinidomTest(unittest.TestCase): doc.unlink() + def testBug0777884(self): + doc = parseString("text") + text = doc.documentElement.childNodes[0] + self.assertEquals(text.nodeType, Node.TEXT_NODE) + # Should run quietly, doing nothing. + text.normalize() + doc.unlink() + def testBug1433694(self): doc = parseString("t") node = doc.documentElement diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py index 02e3b85d4328..12b7afce39ef 100644 --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -890,6 +890,10 @@ class Childless: raise xml.dom.NotFoundErr( self.nodeName + " nodes do not have children") + def normalize(self): + # For childless nodes, normalize() has nothing to do. + pass + def replaceChild(self, newChild, oldChild): raise xml.dom.HierarchyRequestErr( self.nodeName + " nodes do not have children")