From: Andrew M. Kuchling Date: Sat, 23 Feb 2008 17:21:44 +0000 (+0000) Subject: #1433694: minidom's .normalize() failed to set .nextSibling for last element. X-Git-Tag: v2.5.3c1~141 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=05a19a507d8ef57f24d713dd29dcc79494705d18;p=python #1433694: minidom's .normalize() failed to set .nextSibling for last element. Fix by Malte Helmert --- diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index a6d309f7d9..4ace1ebea9 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -806,6 +806,14 @@ def testNormalize(): "testNormalize -- single empty node removed") doc.unlink() +def testBug1433694(): + doc = parseString("t") + node = doc.documentElement + node.childNodes[1].nodeValue = "" + node.normalize() + confirm(node.childNodes[-1].nextSibling == None, + "Final child's .nextSibling should be None") + def testSiblings(): doc = parseString("text?") root = doc.documentElement diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py index 3a35781622..b94a4c71bc 100644 --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -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): diff --git a/Misc/ACKS b/Misc/ACKS index 8cb117f189..c3a0942d29 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -266,6 +266,7 @@ Shane Hathaway Rycharde Hawkes Jochen Hayek Thomas Heller +Malte Helmert Lance Finn Helsten Jonathan Hendry James Henstridge diff --git a/Misc/NEWS b/Misc/NEWS index aec1f2ff42..4d40719e63 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -15,6 +15,10 @@ Core and builtins Library ------- +- Bug #1433694: minidom's .normalize() failed to set .nextSibling for + last child element. + + Extension Modules -----------------