]> granicus.if.org Git - python/commitdiff
#777884: make .normalize() do nothing for childless nodes, instead of raising an...
authorAndrew M. Kuchling <amk@amk.ca>
Sun, 25 Jul 2010 23:38:47 +0000 (23:38 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Sun, 25 Jul 2010 23:38:47 +0000 (23:38 +0000)
Lib/test/test_minidom.py
Lib/xml/dom/minidom.py

index 9a9acfbff3c4c990e4d23e2216ad19e22cf44c3b..d9d3be49c843838c4e319c6244e0fc8ef81cfdaa 100644 (file)
@@ -951,6 +951,14 @@ class MinidomTest(unittest.TestCase):
         doc.unlink()
 
 
+    def testBug0777884(self):
+        doc = parseString("<o>text</o>")
+        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("<o><i/>t</o>")
         node = doc.documentElement
index 7616b46fe0e98a1bf62884a0da459dd394011b24..1beae0cffa52be0698120c16fcf6c0419c25b198 100644 (file)
@@ -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")