[New-bugs-announce] [issue3908] Strange heapq behavior on Python 3.0 when overriding __le__

Giampaolo Rodola' report at bugs.python.org
Fri Sep 19 15:47:31 CEST 2008


New submission from Giampaolo Rodola' <billiejoex at users.sourceforge.net>:

import heapq

class foo:
    def __init__(self):
        self.timeout = 0
    def __le__(self, other):
        return self.timeout <= other.timeout

heap = []
heapq.heappush(heap, foo())
heapq.heappush(heap, foo())


This code on Python 2.x works without problems, by using Python3.0-RC1
it raises the following exception:


    heapq.heappush(heap, foo())
TypeError: unorderable types: foo() < foo()


Note that the previous 3.0 beta didn't have such problem.

----------
components: Library (Lib)
messages: 73425
nosy: giampaolo.rodola
severity: normal
status: open
title: Strange heapq behavior on Python 3.0 when overriding __le__
versions: Python 3.0

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3908>
_______________________________________


More information about the New-bugs-announce mailing list