Message3459

Author tmueller
Recipients tmueller
Date 2008-08-29.17:46:14
SpamBayes Score 2.48337e-07
Marked as misclassified No
Message-id <1220031975.03.0.901498219564.issue1115@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2008-08-29 17:46:15tmuellersetrecipients: + tmueller
2008-08-29 17:46:15tmuellersetmessageid: <1220031975.03.0.901498219564.issue1115@psf.upfronthosting.co.za>
2008-08-29 17:46:14tmuellerlinkissue1115 messages
2008-08-29 17:46:14tmuellercreate