[lxml-dev] Test case that triggers assertion in lxml

This test case triggers an assertion in lxml.etree: def test_iteration5(self): XML = self.etree.XML root = XML('<doc><one/><two>Two</two>Hm<three/></doc>') result = [] for el in root: result.append(el.tag) del root[-1] self.assertEquals(['one', 'two'], result) Output: Proxy: <etree._ElementIterator object at 0x40347920> Proxy type: 3 Exception exceptions.AssertionError: 'Tried to unregister unknown proxy' in 'etree.unregisterProxy' ignored Looks like it unregisters the iterator proxy when its element is GCed. While it is an interesting idea to have the iterator be itself an Element, I wonder if this is viable if you try to avoid such problems. Stefan

Stefan Behnel wrote:
This test case triggers an assertion in lxml.etree:
def test_iteration5(self): XML = self.etree.XML
root = XML('<doc><one/><two>Two</two>Hm<three/></doc>') result = [] for el in root: result.append(el.tag) del root[-1] self.assertEquals(['one', 'two'], result)
Output:
Proxy: <etree._ElementIterator object at 0x40347920> Proxy type: 3 Exception exceptions.AssertionError: 'Tried to unregister unknown proxy' in 'etree.unregisterProxy' ignored
Looks like it unregisters the iterator proxy when its element is GCed. While it is an interesting idea to have the iterator be itself an Element, I wonder if this is viable if you try to avoid such problems.
Hm, I need to review this one. I just fixed a crash error that occured if you manipulated the tail (set it to the emptyh string), but this test case is a different one. I'll look at this (and a lot of other stuff!) after releasing 0.8. Regards, Martijn
participants (2)
-
Martijn Faassen
-
Stefan Behnel