[lxml-dev] the subelements of my tree are moving alone

TP paratribulations at free.fr
Tue Mar 10 18:25:17 CET 2009


Hi everybody,

I have derived custom classes from ET._ElementTree and ET.ElementBase to
obtain a custom tree suited to my needs.

It works perfectly, but it seems that the nodes under the root node (the
subelements) move sometimes "alone". The tree structure is kept, but the
address of the elements in memory is changing. As the structure is kept, it
is not a problem for lxml use only: I can walk in the tree, doing what I
need.

But the problem is that I use this custom tree as the underlying data
structure for a PyQt custom QTreeWidget. In this widget, I use the
method "internalPointer()" of QModelIndex instances (as proposed in the
chapter 16 of book "Rapid GUI Programming with Python
and Qt" by Mark Summerfield (around p.500)).

The problem is that if the nodes move, the "internalPointer()" of Qt are not
up to date: I obtain segmentation faults.

Is this normal that nodes of the tree move in memory *alone*? Is this due to
the garbage collector? If yes, how to keep my pointers up to date?

Thanks in advance

-- 
python -c "print ''.join([chr(154 - ord(c)) for c in '*9(9&(18%.\
9&1+,\'Z4(55l4('])"

"When a distinguished but elderly scientist states that something is
possible, he is almost certainly right. When he states that something is
impossible, he is very probably wrong." (first law of AC Clarke)



More information about the lxml-dev mailing list