[IronPython] Issue overridding __call__

Lyle Thompson LThompson at ixiacom.com
Mon May 14 18:47:06 CEST 2007


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?

Thanks,
Lyle

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
        Callable2.__call__(self)

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)





More information about the Ironpython-users mailing list