[ python-Bugs-1433694 ] normalize function in minidom unlinks empty child nodes

SourceForge.net noreply at sourceforge.net
Fri Feb 17 17:52:32 CET 2006


Bugs item #1433694, was opened at 2006-02-17 11:52
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1433694&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: XML
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: RomanKliotzkin (romankliotzkin)
Assigned to: Nobody/Anonymous (nobody)
Summary: normalize function in minidom unlinks empty child nodes

Initial Comment:
Hi,

When calling the "normalize" method of DOM objects in
the minidom library, the method will attempt to collate
text nodes together. When it encounters an empty text
node, it will do the following:

(line 197 in minidom.py)

  else:                                               
                                    
      # empty text node; discard                      
                                    
      child.unlink()

unlink() sets all the members of the child node to
None, BUT the parent node still has a link to the child
node. Therefore, if one is later iterating through the
parent node and calls removeChild on the unlinked node,
a NotFoundErr exception will be thrown by the library.

To trigger, use the test case script along with the
test case XML document included in the zip file.

testcase.py testcase.xml

My suggestion is to call self.removeChild(child), then
call child.unlink(). That way, there is no ambiguity
about an unlinked child being referenced by the parent.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1433694&group_id=5470


More information about the Python-bugs-list mailing list