This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: minidom replaceChild(new_child, old_child) removes new_child even if in another document
Type: behavior Stage: resolved
Components: XML Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: Martin.Kugler, scoder
Priority: normal Keywords:

Created on 2012-11-07 09:05 by Martin.Kugler, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg175057 - (view) Author: Martin Kugler (Martin.Kugler) Date: 2012-11-07 09:05
Calling doc.replaceChild(new_child, old_child) with new_child and old_child being similar nodes in two different documents results in new_child to be removed from its document instead of old_child being removed from doc.

Example:
        new_child = get_element_x(doc_a)
        old_child = get_element_x(doc_b)
        parent = get_element_y(doc_b)
        parent.replaceChild(new_child, old_child)

=> new_child will be removed from doc_a. Instead old_child should be removed from doc_b.
msg228271 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-10-02 22:31
Who is best placed to look at this as nobody is listed on the experts index?
msg340979 - (view) Author: Stefan Behnel (scoder) * (Python committer) Date: 2019-04-27 11:00
Since "new_child" is inserted at least into a new place, it needs to be removed from its old place as well, so that part seems correct. The problem description does not make it clear whether or not "old_child" is handled correctly, but looking at the code (and lacking a complete example that shows an error), I cannot see anything wrong there.

I'll close this ticket since it has been idle for years and it is unclear to me from the description whether it is an actual misbehaviour or a misunderstanding of correct behaviour.
History
Date User Action Args
2022-04-11 14:57:38adminsetgithub: 60629
2019-04-27 11:00:09scodersetstatus: open -> closed

nosy: + scoder
messages: + msg340979

resolution: works for me
stage: resolved
2019-04-26 18:15:29BreamoreBoysetnosy: - BreamoreBoy
2014-10-02 22:31:15BreamoreBoysetnosy: + BreamoreBoy

messages: + msg228271
versions: + Python 3.4, Python 3.5
2013-10-31 12:56:46eli.benderskysetnosy: - eli.bendersky
2013-10-14 14:16:11georg.brandlsetnosy: + eli.bendersky
2012-11-07 09:05:50Martin.Kuglercreate