FAQ
Can anyone explain why the following fails when using the subclass
(recursion problem), but work using the base class?

It worked with the last "pre-Sourceforge" version of FixedPoint, so I
presume this might be a bug in the latest version -- I just can't for
the life of me see what could cause this!

pm

==================================================
from fixedpoint import FixedPoint

class FP(FixedPoint) :
"""Subclass of FixedPoint"""
def __init__(self, value, precision):
FixedPoint.__init__(self, value, precision)

def _test():
_y = 378
_x = FP(793.1 , 6)
#_x = FixedPoint(793.1 , 6)
_z = _y/_x
print type(_y) , ' : ' , _y
print type(_x) , ' : ' , _x
print type(_z) , ' : ' , _z

if __name__ == '__main__':
_test()

Search Discussions

  • Dougfort at Oct 15, 2002 at 11:02 am

    On Tue, 15 Oct 2002, paul at nlhas.no wrote:
    Can anyone explain why the following fails when using the subclass
    (recursion problem), but work using the base class?

    It worked with the last "pre-Sourceforge" version of FixedPoint, so I
    presume this might be a bug in the latest version -- I just can't for
    the life of me see what could cause this!

    pm
    I presume it's a bug too. I'm tied up with my day job right now. I'll look into
    it when I get the chance. I fear it's related to the use of __slots__, which I
    threw in just because it sounded cool. You might want to report an official bug
    at the SourceForge site: that leaves less chance of it slipping through the
    cracks.

    Doug Fort <dougfort at dougfort.net>
    http://www.dougfort.net
  • Tim Peters at Oct 15, 2002 at 6:04 pm
    [posted & mailed]

    [paul at nlhas.no]
    Can anyone explain why the following fails when using the subclass
    (recursion problem), but work using the base class?
    [Doug Fort]
    I presume it's a bug too. I'm tied up with my day job right now.
    I'll look into it when I get the chance. I fear it's related to
    the use of __slots__, which I threw in just because it sounded cool.
    I've opened a bug report against Python on this:

    http://www.python.org/sf/623669

    __slots__ are irrelevant here, but deriving from object is not. I'm unclear
    on whether the change in behavior was intentional or is just a bug, so
    assigned that report to Guido for clarification. A brute-force workaround
    (immune to choice of old-style vs new-style class) is explained at the
    bottom of that bug report.
  • Doug Fort at Oct 15, 2002 at 9:20 pm

    On Tue, 15 Oct 2002 14:04:42 +0000, Tim Peters wrote:

    [posted & mailed]

    [paul at nlhas.no]
    Can anyone explain why the following fails when using the subclass
    (recursion problem), but work using the base class?
    [Doug Fort]
    I presume it's a bug too. I'm tied up with my day job right now.
    I'll look into it when I get the chance. I fear it's related to
    the use of __slots__, which I threw in just because it sounded cool.
    I've opened a bug report against Python on this:

    http://www.python.org/sf/623669

    __slots__ are irrelevant here, but deriving from object is not. I'm unclear
    on whether the change in behavior was intentional or is just a bug, so
    assigned that report to Guido for clarification. A brute-force workaround
    (immune to choice of old-style vs new-style class) is explained at the
    bottom of that bug report.
    Paul opened a bug against FixedPoint (#623491). I have assigned it to Joe,
    because he found some problems with subclassing FixedPoint that are
    unrelated to division.

    I'm going to add some unit tests with subclasses to see if we can shake
    out any more problems.

    I don't think we're going to put out a new release for this. Joe should
    have his fixes in CVS shortly.
    --
    Doug Fort, Programmer
    http:/www.dougfort.net

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedOct 15, '02 at 8:32a
activeOct 15, '02 at 9:20p
posts4
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase