[IronPython] IP2b5 - error in calling bound method from C#?

Ronnie Maor ronnie.maor at gmail.com
Mon Sep 22 15:29:57 CEST 2008

I think this is a bug and not some silly mistake on my part...
not sure exactly which flows this effects, but here is a small repro:

import System.Threading

def cb(state):
    print "CB CALLED"

class Timer(object):
    def __init__(self,delay,interval):
        def _inner_cb(state):
            print "INNER CALLED"
        f = self._callback # this is the problematic variant
        #f = cb
        #f = _inner_cb

        self.timer = System.Threading.Timer(f,None,delay,interval)

    def _callback(self,state): # state parameter is required as part of
TimerCallback signature. ignore it.
        print "CALLBACK CALLED"

t = Timer(1000,0)
print "Sleeping..."
print "Woke up"

------------------ (end code)

C:\IronPython\2.0\IronPython-2.0B5>ipy \data\trunk\src\Itst.Backend\tmp.py
Traceback (most recent call last):
  File "\data\trunk\src\Itst.Backend\tmp.py", line 20, in
  File "\data\trunk\src\Itst.Backend\tmp.py", line 15, in __init__
TypeError: Value cannot be null.
Parameter name: context

The code works when you change f to one of the other variants (cb or
For now I'm going to use _inner_cb variant as a workaround so I can continue
porting my code and map other issues.

one note if/when comparing with IPy 1.1. The overload resolution was not as
good there, so you need to change the call to Timer to:
        Timer_ctor =
        self.timer =
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080922/167f68da/attachment.html>

More information about the Ironpython-users mailing list