Definitely a bug - it also repros on the desktop CLR. It repros with just:
from __future__ import with_statement with file('hello.txt', 'w') as f: raise Exception so it looks like the exception code path is broken. The underlying problem is that we end up trying to dynamically convert void -> bool which doesn't work. Ultimately this is a defect in the way that we deal with return values in dynamic sites. We're doing some work to clean this up (it works on one of my enlistments already :) ) so it'll probably be fixed for beta 4. I've opened bug #17323 to track it - http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=17323. Thanks for the bug report! -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dan Eloff Sent: Tuesday, July 08, 2008 6:27 PM To: Discussion of IronPython Subject: [IronPython] Possible bug with "with" statement In silverlight, using ipy 2.0b3, I get the following error, but it goes away if I replace the with statement with it's try/finally equiv. I tried to make a minimal reproduction of this but could not. I thought I should post this traceback in case I did find a bug. -Dan ValueError: The type 'System.Void' may not be used as a type argument. beskar\parser.py Line 26: self.compiler = Compiler(self, path, context) Line 27: with file(path, 'rb') as f: Line 28: return self.parse(f.read(), path) Line 29: Line 30: def load_string(self, name, source, context): ValueError at load in beskar\parser.py, line 28 at load in beskar\loader.py, line 18 at load in game\templates\__init__.py, line 8 at load_xaml in game\templates\__init__.py, line 11 at bug in game\__init__.py, line 27 at global_hotkeys in game\hotkeys.py, line 19 CLR Stack Trace: at System.RuntimeType.ThrowIfTypeNeverValidGenericArgument(Type type) at System.RuntimeType.SanityCheckGenericArguments(Type[] genericArguments, Type[] genericParamters) at System.RuntimeType.MakeGenericType(Type[] instantiation) at Microsoft.Scripting.Actions.DynamicSiteHelpers.MakeDynamicSiteTargetType(Type[] types) at Microsoft.Scripting.Actions.DynamicSiteHelpers.MakeDynamicSiteType(Type[] types) at Microsoft.Scripting.Ast.DynamicNodeRewriter.RewriteSite(CallSiteBinder bindingInfo, Type retType, IList`1 args) at Microsoft.Scripting.Ast.DynamicNodeRewriter.Rewrite(ActionExpression node) at Microsoft.Scripting.Ast.TreeRewriter.DefaultRewriteActionExpression(TreeRewriter rewriter, Expression n) at Microsoft.Scripting.Ast.TreeRewriter.RewriteNode(Expression node) at Microsoft.Scripting.Ast.TreeRewriter.DefaultRewriteReturnStatement(TreeRewriter rewriter, Expression n) at Microsoft.Scripting.Ast.TreeRewriter.RewriteNode(Expression node) at Microsoft.Scripting.Ast.TreeRewriter.DefaultRewriteConditionalExpression(TreeRewriter rewriter, Expression n) at Microsoft.Scripting.Ast.TreeRewriter.RewriteNode(Expression node) at Microsoft.Scripting.Ast.TreeRewriter.DefaultRewriteScopeExpression(TreeRewriter rewriter, Expression n) at Microsoft.Scripting.Ast.TreeRewriter.RewriteNode(Expression node) at Microsoft.Scripting.Ast.TreeRewriter.RewriteArray(IList`1 args) at Microsoft.Scripting.Ast.TreeRewriter.DefaultRewriteBlock(TreeRewriter rewriter, Expression n) at Microsoft.Scripting.Ast.TreeRewriter.RewriteNode(Expression node) at Microsoft.Scripting.Ast.TreeRewriter.DefaultRewriteLambdaExpression(TreeRewriter rewriter, Expression n) at Microsoft.Scripting.Ast.TreeRewriter.RewriteNode(Expression node) at Microsoft.Scripting.Ast.LambdaCompiler.AnalyzeLambda(LambdaExpression& lambda) at Microsoft.Scripting.Ast.LambdaCompiler..ctor(Compiler compiler, LambdaExpression lambda, TypeGen typeGen, MethodBase mi, ILGenerator ilg, IList`1 paramTypes, ConstantPool constantPool, Boolean closure, Boolean emitDebugSymbols) at Microsoft.Scripting.Ast.LambdaCompiler.CreateDynamicLambdaCompiler(Compiler compiler, LambdaExpression lambda, String methodName, Type returnType, IList`1 paramTypes, IList`1 paramNames, ConstantPool constantPool, Boolean closure, Boolean emitDebugSymbols) at Microsoft.Scripting.Ast.LambdaCompiler.CompileLambda(LambdaExpression lambda, Type delegateType, Boolean emitDebugSymbols, MethodInfo& method) at Microsoft.Scripting.Ast.LambdaCompiler.CompileLambda[T](LambdaExpression lambda, MethodInfo& method) at Microsoft.Scripting.Actions.SmallRuleSet`1.MakeTarget() at Microsoft.Scripting.Actions.SmallRuleSet`1.GetTarget() at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args) at Microsoft.Scripting.Actions.UpdateDelegates.Update3[T,T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2) at S$40.load$1320(Closure , Object self, Object path, Object context) at _stub_$3707##2295(Closure , CallSite , CodeContext , Object , Object , Object , Object ) at _stub_MatchCaller(Object , CallSite , Object[] ) at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args) at Microsoft.Scripting.Actions.UpdateDelegates.Update5[T,T0,T1,T2,T3,T4,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4) at _stub_$3706##2294(Closure , CallSite , CodeContext , Object , Object , Object ) at _stub_MatchCaller(Object , CallSite , Object[] ) at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args) at Microsoft.Scripting.Actions.UpdateDelegates.Update4[T,T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at S$42.load$1489(Closure , Object path, Object namespaces) at S$42.load$1489(Closure , Object[] ) at _stub_$3668##2256(Closure , CallSite , CodeContext , Object , Object ) at _stub_MatchCaller(Object , CallSite , Object[] ) at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args) at Microsoft.Scripting.Actions.UpdateDelegates.Update3[T,T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2) at S$26.load$909(Closure , Object template) at _stub_$1047##540(Closure , CallSite , CodeContext , Object , Object ) at _stub_MatchCaller(Object , CallSite , Object[] ) at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args) at Microsoft.Scripting.Actions.UpdateDelegates.Update3[T,T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2) at S$26.load_xaml$910(Closure , Object template, Object namespaces) at S$26.load_xaml$910(Closure , Object[] ) at _stub_$3664##2252(Closure , CallSite , CodeContext , Object , String , Object ) at _stub_MatchCaller(Object , CallSite , Object[] ) at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args) at Microsoft.Scripting.Actions.UpdateDelegates.Update4[T,T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at S$4.bug$384(Closure ) at _stub_$375##345(Closure , CallSite , CodeContext , Object ) at _stub_MatchCaller(Object , CallSite , Object[] ) at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args) at Microsoft.Scripting.Actions.UpdateDelegates.Update2[T,T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) at S$80.global_hotkeys$3425(Closure , Object sender, Object e) at _stub_$3654##2242(Closure , CallSite , CodeContext , Object , Object , Object ) at _stub_MatchCaller(Object , CallSite , Object[] ) at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args) at Microsoft.Scripting.Actions.UpdateDelegates.Update4[T,T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at System.Void(Object, KeyEventArgs)(Object[] , Object , KeyEventArgs ) at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName) _______________________________________________ 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