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