Issue1115

classification
Title: __lt__ in a derived list produces a StackOverflowError
Type: behaviour Severity: major
Components: Core Versions: 2.5alpha1
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: pjenvey Nosy List: pjenvey, tmueller
Priority: Keywords:

Created on 2008-08-29.17:46:14 by tmueller, last changed 2008-11-08.00:08:35 by pjenvey.

Messages
msg3459 (view) Author: Tom Mueller (tmueller) Date: 2008-08-29.17:46:14
Consider the following class: 

class derivedlist(list):
    def __init__(self, dotstring):
        list.__init__(self, map(int, dotstring.split(".")))

    def __str__(self):
        return ".".join(map(str, self))

Then do the following:

d1 = derivedlist.derivedlist("1.2.3")
d2 = derivedlist.derivedlist("1.2.4")
d1 < d2

This last operation produces a StackOverflowError. 

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
java.lang.StackOverflowError
        at
org.python.core.PyBuiltinFunction.<init>(PyBuiltinFunction.java:13)
        at org.python.core.PyBuiltinMethod.<init>(PyBuiltinMethod.java:10)
        at
org.python.core.PyBuiltinMethodNarrow.<init>(PyBuiltinMethodNarrow.java:16)
        at org.python.core.PyList$list___lt___exposer.<init>(Unknown Source)
        at org.python.core.PyList$list___lt___exposer.bind(Unknown Source)
        at
org.python.core.PyMethodDescr.method_descriptor___get__(PyMethodDescr.java:66)
        at org.python.core.PyMethodDescr.__get__(PyMethodDescr.java:59)
        at org.python.core.PyListDerived.__lt__(PyListDerived.java:485)
        at org.python.core.PySequence.seq___lt__(PySequence.java:150)
        at org.python.core.PyList.list___lt__(PyList.java:246)
        at org.python.core.PyList$list___lt___exposer.__call__(Unknown
Source)

These last 4 lines are repeated dozens of times. 

I used the following to definition of the __lt__ method in the
derivedlist class to work around this problem:

        def __lt__(self, other):
                if other is None: 
                        return False
                l1 = list(self)
                l2 = list(other)
                return l1 < l2
msg3759 (view) Author: Philip Jenvey (pjenvey) Date: 2008-11-08.00:08:35
fixed in r5557. thanks!
History
Date User Action Args
2008-11-08 00:08:35pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg3759
2008-11-07 23:46:52pjenveysetassignee: pjenvey
nosy: + pjenvey
2008-08-29 17:46:14tmuellercreate