welcome. pleasure doing business with you :-) On Wed, Jan 27, 2010 at 8:08 PM, Dino Viehland <di...@microsoft.com> wrote:
> It’s so easy to fix it’s actually already fixed for 2.6.1 J Thanks for > reporting it though. > > > > *From:* users-boun...@lists.ironpython.com [mailto: > users-boun...@lists.ironpython.com] *On Behalf Of *Ronnie Maor > *Sent:* Wednesday, January 27, 2010 8:17 AM > *To:* Discussion of IronPython > *Subject:* [IronPython] bug with closure in coroutine > > > > Hi IronPython team, > > > > Seems IronPython 2.6 has some problems with compiling coroutines that > contain closures: > > > > tmp.py: > > def coroutine(): > > x = yield 3 > > def inner(): > > print 'x=',x > > inner() > > > > c = coroutine() > > c.next() > > c.send(10) > > > > with CPython: > > C:\Temp>python tmp.py > > x= 10 > > Traceback (most recent call last): > > File "tmp.py", line 9, in <module> > > c.send(10) > > StopIteration > > > > > > with IronPython 2.6: > > C:\Temp>ipy tmp.py > > Traceback (most recent call last): > > File "tmp.py", line 7, in tmp.py > > TypeError: Unable to cast object of type > 'Microsoft.Scripting.Ast.FieldExpression' to type > 'Microsoft.Scripting.Ast.BlockExpression'. > > > > > > workarounds: > > 1) re-assign the result returned from yield to another variable > > def coroutine(): > > tmp_x = yield 3 > > x = tmp_x > > def inner(): > > print 'x=',x > > inner() > > > > 2) pass the value explicitly instead of using a closure > > def coroutine(): > > x = yield 3 > > def inner(x): > > print 'x=',x > > inner(x) > > > > hope it's easy to fix > > > > thanks > > Ronnie > > _______________________________________________ > Users mailing list > Users@lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > >
_______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com