Comment 5 for bug 1206866

Revision history for this message
Barry Warsaw (barry) wrote : Re: Dies with dotted version numbers? - TypeError: unorderable types: Image() < Image()

I figured this out.

Let's say two candidate upgrade paths have the exact same score, e.g. 40. When we zip the score with the candidates, we'll have a structure roughly like this:

[..., (40, [Image, Image, Image]), (40, [Image, Image, Image]), ...]

When we go to sort this, the default sorting algorithm for tuples is to sort on the first element, then the second element, etc. The first element will be equal, so it will fall back to sorting on the second element. *That* falls back to comparing the lists, which falls back to comparing the individual Images in each list. Images aren't comparable, thus the traceback.

The solution is to add a second element to the sorted tuples which is an ordinal that will never appear twice. That way, the above structure would look like:

[..., (40, 12, [Image, Image, Image]), (40, 13, [Image, Image, Image]), ...]

so sorting will never fallback to the list of Images.