diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2005-11-22 19:03:16 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2005-11-22 19:03:16 (GMT) |
commit | 841d25ee664d7e77caa6169401f9dff696c738da (patch) | |
tree | 595279cb2d688651a1954cbbaacf0d4854c06a8e /Lib/xml | |
parent | bb7e800506c5d27c9105bc47b09ac368dddb4492 (diff) | |
download | cpython-841d25ee664d7e77caa6169401f9dff696c738da.zip cpython-841d25ee664d7e77caa6169401f9dff696c738da.tar.gz cpython-841d25ee664d7e77caa6169401f9dff696c738da.tar.bz2 |
[Patch #1094164] replaceChild(x,x) ends up removing x of the tree. Add fix from Felix Rabe and a test case
Diffstat (limited to 'Lib/xml')
-rw-r--r-- | Lib/xml/dom/minidom.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py index 4bb4ef4..84be99b 100644 --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -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: |