From: Andrew M. Kuchling Date: Sun, 25 Jul 2010 23:38:47 +0000 (+0000) Subject: #777884: make .normalize() do nothing for childless nodes, instead of raising an... X-Git-Tag: v3.2a1~106 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=688b9e384e065a1b63dcf4c2237e70ac180658a0;p=thirdparty%2FPython%2Fcpython.git #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 9a9acfbff3c4..d9d3be49c843 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -951,6 +951,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 7616b46fe0e9..1beae0cffa52 100644 --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -920,6 +920,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")