[IronPython] Blocker: subclasses of float have trouble with __int__ and __str__

Dino Viehland dinov at microsoft.com
Fri Nov 21 19:52:43 CET 2008

We're going to fix this bug a couple of others (in addition to the couple fixed in the current sources) and release an RC2.

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Glenn Jones
Sent: Thursday, November 20, 2008 4:33 AM
To: users at lists.ironpython.com
Subject: [IronPython] Blocker: subclasses of float have trouble with __int__ and __str__

Hello guys,

On the latest code drop (43741) it seems that something is broken in subclasses of floats.

class MyFloatType(float):
  def __new__(cls):
    return float.__new__(cls, 0.0)

  def __repr__(self):
    return "MyFloat"

  __str__ = __repr__

>>>MyFloat = MyFloatType()
TypeError: expected int, got p

This is one can be worked around by having an __int__ defined. However,


Subclassing longs and ints in a similar way has the correct behaviour.

This is nasty and a blocker for us.

We've raised this as Issue 19675

Glenn & Orestis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20081121/d29a4b99/attachment.html>

More information about the Ironpython-users mailing list