Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#5328 enhancement closed fixed (fixed)

Avoid relying on sortability of incompatible types

Reported by: Antoine Pitrou Owned by:
Priority: normal Milestone: Python-3.x
Component: core Keywords:
Cc: Antoine Pitrou Branch:


test_dirdbm relies on sorting arbitrary types, which fails under Python 3:

>>> 1 < None
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unorderable types: int() < NoneType()

It is reasonable to use a set instead. Patch attached.

Attachments (1)

test_dirdbm_sort.patch (1.8 KB) - added by Antoine Pitrou 10 years ago.

Download all attachments as: .zip

Change History (4)

Changed 10 years ago by Antoine Pitrou

Attachment: test_dirdbm_sort.patch added

comment:1 Changed 10 years ago by Antoine Pitrou

Cc: Antoine Pitrou added
Keywords: review added

comment:2 Changed 10 years ago by itamarst

Resolution: fixed
Status: newclosed

(In [33011]) Python 3 compatibility for

Fixes: #5328 Author: antoine Review: itamar

Python 3 doesn't support sorting non-comparable types, so use set instead of sorted list.

comment:3 Changed 10 years ago by Jean-Paul Calderone

Keywords: review removed

Presumably itamar meant to remove the review keyword, since it seems he reviewed this in order to decide to merge it. I'll steal the credit to teach him a lesson about tracker hygiene.

Note: See TracTickets for help on using tickets.