[Python-bugs-list] [ python-Bugs-442833 ] 2.2a1: __int__ and multiple inheritance
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 19 Jul 2001 11:42:38 -0700
Bugs item #442833, was opened at 2001-07-19 11:29
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=442833&group_id=5470
Category: type/class unification
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Walter Dörwald (doerwalter)
Assigned to: Guido van Rossum (gvanrossum)
Summary: 2.2a1: __int__ and multiple inheritance
Initial Comment:
The __int__ special method doesn't seem to be
inherited correctly somehow when multiple inheritance
is involved:
----
class Node(object):
def __int__(self):
return int(self.str())
def str(self):
return "23"
class Frag(Node, list):
def str(self):
return "42"
print Node().__int__()
print int(Node())
print Frag().__int__()
print int(Frag())
----
Output is:
----
23
23
42
Traceback (most recent call last):
File "xsc.py", line 14, in ?
print int(Frag())
TypeError: object can't be converted to int
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-07-19 11:42
Message:
Logged In: YES
user_id=6380
Right again. This will take some time to fix... I believe
I currently only look in the "primary" base class for
special slots, where the "primary" base class in your
example is 'list'.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=442833&group_id=5470