[XML-SIG] Re: xml.dom.core bugfix

Andrew M. Kuchling akuchlin@cnri.reston.va.us
Fri, 26 Mar 1999 10:51:20 -0500 (EST)


Carsten Oberscheid writes:
>there was a little bug in xml.dom.core.replaceChild, in the 
>"newChild == DOCUMENT_FRAGMENT" part. Hope the fix is ok...

	Thanks for the changes.  Could you show me the testcase that
demonstrated why this is broken?  Your patch is:

*** core.py	Mon Mar 22 09:15:04 1999
--- /tmp/core.py	Fri Mar 26 10:01:44 1999
***************
*** 496,501 ****
                  if newChild._node.type == DOCUMENT_FRAGMENT_NODE:
                      L[i:i+1] = newChild._node.children
! 	            for child in newchild._node.children:
! 	                self._set_parentdict(id(newChild._node), self._node)
                      newChild._node.children = []
                  else:
--- 495,501 ----
                  if newChild._node.type == DOCUMENT_FRAGMENT_NODE:
                      L[i:i+1] = newChild._node.children
!                     for child in newChild._node.children:
!                         self._node.children.append(child)
!                         self._set_parentdict(id(child), self._node)
                      newChild._node.children = []
                  else:

The change to the _set_parentdict() call is correct; that's definitely
a bug.  But I don't see why the self._node.children.append() call is
required, because the L[i:i+1] should be adding the new children to
the node; L has been set to self._node.children just above the patch
location.

-- 
A.M. Kuchling			http://starship.python.net/crew/amk/
Consumers are like roaches -- you spray them and they get immune after a while.
    -- David Lubars