]> granicus.if.org Git - python/commitdiff
#1433694: minidom's .normalize() failed to set .nextSibling for last element.
authorAndrew M. Kuchling <amk@amk.ca>
Sat, 23 Feb 2008 17:10:46 +0000 (17:10 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Sat, 23 Feb 2008 17:10:46 +0000 (17:10 +0000)
Fix by Malte Helmert

Lib/test/test_minidom.py
Lib/xml/dom/minidom.py
Misc/ACKS

index 3058b303068569cf849f91f442a0fbf0d26268f2..fcc4c8fec3728426da657185f74a691fe1eba207 100644 (file)
@@ -791,6 +791,14 @@ class MinidomTest(unittest.TestCase):
                 "testNormalize -- single empty node removed")
         doc.unlink()
 
+    def testBug1433694(self):
+        doc = parseString("<o><i/>t</o>")
+        node = doc.documentElement
+        node.childNodes[1].nodeValue = ""
+        node.normalize()
+        self.confirm(node.childNodes[-1].nextSibling == None,
+                     "Final child's .nextSibling should be None")
+
     def testSiblings(self):
         doc = parseString("<doc><?pi?>text?<elm/></doc>")
         root = doc.documentElement
index 40e39f861db749b8241ce4340318c2a9eece1bc3..ae960330c5bda69e2453df75835e20bd8db3fafe 100644 (file)
@@ -203,6 +203,8 @@ class Node(xml.dom.Node):
                 L.append(child)
                 if child.nodeType == Node.ELEMENT_NODE:
                     child.normalize()
+        if L:
+            L[-1].nextSibling = None
         self.childNodes[:] = L
 
     def cloneNode(self, deep):
index 8c037840dbd9033c1101d207bccf022452bad023..794b1f427dc75493c52cce4e5ee52135bb6de1ab 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -274,6 +274,7 @@ Shane Hathaway
 Rycharde Hawkes
 Jochen Hayek
 Thomas Heller
+Malte Helmert
 Lance Finn Helsten
 Jonathan Hendry
 James Henstridge