pymods icon indicating copy to clipboard operation
pymods copied to clipboard

Element comparison errors when sorting NamedTuples

Open mrmiguez opened this issue 6 years ago • 0 comments

Some pymods.Record functions that return sorted lists of NamedTuples including lxml elements cause comparison error when there is a repeated element.

Given the structure:

<name>
  <namePart>Cash</namePart>
</name>
<name>
  <namePart>Cash</namePart>
</name>

pymods will create the tuples: Name('Cash', '', '', '', '', '', lxml.Element pointer A) Name('Cash', '', '', '', '', '', lxml.Element pointer B)

The only unique tuple element for sorting is the element pointer, but comparisons between lxml.Elements is not allowed:

TypeError: '<' not supported between instances of 'lxml.etree._Element' and 'lxml.etree._Element'

Really there's no reason for any pymods.Record function or property to return a sorted list. Removing the sort()'s would easily fix this.

mrmiguez avatar Jan 24 '19 18:01 mrmiguez