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

Ronnie Maor ronnie.maor at gmail.com
Mon Sep 22 19:38:37 CEST 2008


On Mon, Sep 22, 2008 at 6:50 PM, Dino Viehland <dinov at microsoft.com> wrote:

>  FYI this is the same as bug #18345 -
> http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=18345
>
> ok. I'll go over active tickets so I have a better picture of what to
expect


We'll fix this for the RC.
>
great.

>
>
> *From:* users-bounces at lists.ironpython.com [mailto:
> users-bounces at lists.ironpython.com] *On Behalf Of *Ronnie Maor
> *Sent:* Monday, September 22, 2008 6:39 AM
> *To:* Discussion of IronPython
> *Subject:* Re: [IronPython] IP2b5 - error in calling bound method from C#?
>
>
>
> 2nd attempt at defining the problem:
> "problem assigning bound method to delegate?"
> that's my last try. now someone who actually has a clue needs to look at it
> :-)
>
> On Mon, Sep 22, 2008 at 3:29 PM, Ronnie Maor <ronnie.maor at gmail.com>
> wrote:
>
> 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"
>             self._callback(None)
>         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..."
> System.Threading.Thread.CurrentThread.Join(2000)
> 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
> \data\trunk\src\Itst.Backend\tmp.py
>   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
> _inner_cb).
> 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 =
> System.Threading.Timer.__new__.Overloads[(System.Threading.TimerCallback,object,int,int)]
>         self.timer =
> Timer_ctor(System.Threading.Timer,f,None,delay,interval)
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080922/9e4f44c7/attachment.html>


More information about the Ironpython-users mailing list