[Patch #1094164] replaceChild(x,x) ends up removing x of the tree. Add fix from Felix Rabe and a test case

This commit is contained in:
Andrew M. Kuchling 2005-11-22 19:03:16 +00:00
parent bb7e800506
commit 841d25ee66
2 changed files with 13 additions and 2 deletions

View file

@ -135,10 +135,10 @@ class Node(xml.dom.Node, GetattrMagic):
if newChild.nodeType not in self._child_node_types:
raise xml.dom.HierarchyRequestErr(
"%s cannot be child of %s" % (repr(newChild), repr(self)))
if newChild.parentNode is not None:
newChild.parentNode.removeChild(newChild)
if newChild is oldChild:
return
if newChild.parentNode is not None:
newChild.parentNode.removeChild(newChild)
try:
index = self.childNodes.index(oldChild)
except ValueError: