[IronPython] Issue overridding __call__

Dino Viehland dinov at exchange.microsoft.com
Mon May 14 22:53:23 CEST 2007

Thanks for the bug report.  I believe this is the same as bug #7594 (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=7594).  We've already fixed that in the v2.0 branch (where types are behaving quite differently than they were in v1.x).

Could you vote on the issue - that way we can keep track of its effect and potentially back port it in the future.

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Lyle Thompson
Sent: Monday, May 14, 2007 9:47 AM
To: users at lists.ironpython.com
Subject: [IronPython] Issue overridding __call__

I think I may have found a bug in IP1.1. I have a class hierarchy of
callable objects, shown below. The problem appears to be that Ipy
confuses __call__ with __init__. I have found that if I use super for
line 19, then the problem moves to line 20, for which I have no
workaround. Any ideas?


class Callable1(object):
    def __init__(self):
        print "calling Callable1.__init__"

    def __call__(self):
        print "calling Callable1.__call__"

class Callable2(object):
    def __init__(self):
        print "calling Callable2.__init__"

    def __call__(self):
        print "calling Callable2.__call__"

class Callable1And2(Callable1, Callable2):
    def __call__(self):
        Callable1.__call__(self)                # <--- line 19

c = Callable1And2()
c()                                                     # <---- line 23

This gives me the following error:

Traceback (most recent call last):
  File , line 0, in <stdin>##10
  File , line 0, in __import__##4
  File d:\p4\ixweb3\3.30\Client\callable.py, line 23, in Initialize
  File d:\p4\ixweb3\3.30\Client\callable.py, line 19, in __call__
TypeError: __init__() takes exactly 1 argument (2 given)

users mailing list
users at lists.ironpython.com

More information about the Ironpython-users mailing list