From 19aff0c90a1632fce527d7c81769ba419184700c Mon Sep 17 00:00:00 2001 From: "Andrew M. Kuchling" Date: Sat, 23 Feb 2008 17:10:46 +0000 Subject: [PATCH] #1433694: minidom's .normalize() failed to set .nextSibling for last element. Fix by Malte Helmert --- Lib/test/test_minidom.py | 8 ++++++++ Lib/xml/dom/minidom.py | 2 ++ Misc/ACKS | 1 + 3 files changed, 11 insertions(+) diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index 3058b303068..fcc4c8fec37 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -791,6 +791,14 @@ class MinidomTest(unittest.TestCase): "testNormalize -- single empty node removed") doc.unlink() + def testBug1433694(self): + doc = parseString("t") + 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("text?") root = doc.documentElement diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py index 40e39f861db..ae960330c5b 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 8c037840dbd..794b1f427dc 100644 --- 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