Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xml.dom.minidom.Node.removeChild() doesn't remove #41659

Closed
mkempka mannequin opened this issue Mar 6, 2005 · 4 comments
Closed

xml.dom.minidom.Node.removeChild() doesn't remove #41659

mkempka mannequin opened this issue Mar 6, 2005 · 4 comments

Comments

@mkempka
Copy link
Mannequin

mkempka mannequin commented Mar 6, 2005

BPO 1157901
Files
  • dombug.py: code to demonstrate the bug
  • errorintroducer.xml: the xml file that produces the error
  • errorfree.xml: the (almost) same contents that don't produce the error
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2005-05-20.21:44:01.000>
    created_at = <Date 2005-03-06.21:17:08.000>
    labels = ['expert-XML', 'invalid']
    title = "xml.dom.minidom.Node.removeChild() doesn't remove"
    updated_at = <Date 2005-05-20.21:44:01.000>
    user = 'https://bugs.python.org/mkempka'

    bugs.python.org fields:

    activity = <Date 2005-05-20.21:44:01.000>
    actor = 'mkempka'
    assignee = 'none'
    closed = True
    closed_date = None
    closer = None
    components = ['XML']
    creation = <Date 2005-03-06.21:17:08.000>
    creator = 'mkempka'
    dependencies = []
    files = ['1620', '1621', '1622']
    hgrepos = []
    issue_num = 1157901
    keywords = []
    message_count = 4.0
    messages = ['24480', '24481', '24482', '24483']
    nosy_count = 2.0
    nosy_names = ['mkempka', 'bobince']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1157901'
    versions = ['Python 2.3']

    @mkempka
    Copy link
    Mannequin Author

    mkempka mannequin commented Mar 6, 2005

    There seems to be a constellation where
    xml.dom.minidom.Node.removeChild() doesn't remove
    childs properly.

    I found this bug in 2.3.4 and it is still in:

    Python 2.3.5 (#2, Feb 9 2005, 00:38:15)
    [GCC 3.3.5 (Debian 1:3.3.5-8)] on linux2

    I attached 3 files, the dombug.py demonstrates the
    problem:

    First, I iterate over all children of a specific
    element, check their tag name and remove them using
    removeChild() and then child.unlink().
    After the elements are removed I iterate again, do the
    same check for a tag and find there are still elements
    in there. That is, there are still elements in there
    when I parse the file errorintroducer.xml. When I parse
    the file errorfree.xml the elements are all removed.

    The difference between the xml files is the carriage
    return after each closing tag.

    Since to my knowledge both xml files are well-formed I
    would expect in both cases that all elements are removed.

    @mkempka mkempka mannequin closed this as completed Mar 6, 2005
    @mkempka mkempka mannequin closed this as completed Mar 6, 2005
    @mkempka
    Copy link
    Mannequin Author

    mkempka mannequin commented Mar 6, 2005

    Logged In: YES
    user_id=736381

    so.. this form posts the error report with uploading
    files...interesting...

    Anyway, the output I get when running the program with
    errorintroducer.xml is:

    python dombug.py
    found element 1
    .. removed
    found element 3
    .. removed
    found element 5
    .. removed
    -----------everything removed from timerList[0]---------------
    found Element 2
    found Element 4
    found Element 6

    imho it should be, as it is with errorfree.xml:

    found element 1
    .. removed
    found element 2
    .. removed
    found element 3
    .. removed
    found element 4
    .. removed
    found element 5
    .. removed
    found element 6
    .. removed
    -----------everything removed from timerList[0]---------------

    @bobince
    Copy link
    Mannequin

    bobince mannequin commented Mar 11, 2005

    Logged In: YES
    user_id=311085

    Bug should be marked INVALID.

    childNodes lists are 'live'. You are iterating over a list
    you are destroying at the same time. The code is equivalent
    to the more obviously broken:

      foo= [1, 2, 3, 4]
      i= 0
      while i<len(foo):
        del foo[i]
        i+= 1
      foo
      >>> [2, 4]

    The 'working' example only works because it has extra
    whitespace nodes in, so when you delete child number i, the
    child i+1 that is skipped over is a Text node containing
    only whitespace.

    BTW, there's a separate bug tracker for the PyXML project
    from which minidom is taken. You may get better results by
    submitting there (and discussing on the XML-SIG list).

    @mkempka
    Copy link
    Mannequin Author

    mkempka mannequin commented May 20, 2005

    Logged In: YES
    user_id=736381

    well then, invalid.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    No branches or pull requests

    0 participants