[Ironpython-users] ValueError in IronPython 2.7.1 beta

Dino Viehland dinov at microsoft.com
Wed Aug 24 19:16:10 CEST 2011

Repros for me too - The exception is coming from here:

An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at Microsoft.Scripting.Debugging.DebuggableLambdaBuilder.LayOutVariables(Dictionary`2 strongBoxedLocals, Dictionary`2 parameters)
   at Microsoft.Scripting.Debugging.DebuggableLambdaBuilder.TransformLambda(LambdaExpression lambda)
   at Microsoft.Scripting.Debugging.DebuggableLambdaBuilder.Transform(LambdaExpression lambda)
   at Microsoft.Scripting.Debugging.CompilerServices.DebugContext.TransformLambda(LambdaExpression lambda, DebugLambdaInfo lambdaInfo)
   at IronPython.Runtime.FunctionCode.<>c__DisplayClass1a.<GetGeneratorOrNormalLambdaTracing>b__19(Expression`1 x)
   at IronPython.Compiler.GeneratorRewriter.Reduce(Boolean shouldInterpret, Boolean emitDebugSymbols, Int32 compilationThreshold, IList`1 parameters, Func`2 bod
   at IronPython.Runtime.FunctionCode.GetGeneratorOrNormalLambdaTracing(PythonContext context)
   at IronPython.Runtime.FunctionCode.UpdateDelegate(PythonContext context, Boolean forceCreation)
   at IronPython.Runtime.FunctionCode.LazyCompileFirstTarget(PythonFunction function)
   at IronPython.Compiler.PythonCallTargets.OriginalCallTarget4(PythonFunction function, Object arg0, Object arg1, Object arg2, Object arg3)
   at IronPython.Runtime.PythonFunction.FunctionCaller`1.Default3Call1(CallSite site, CodeContext context, Object func, T0 arg0)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
   at Microsoft.Scripting.Interpreter.DynamicInstruction`4.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
   at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
   at IronPython.Compiler.PythonScriptCode.Run(Scope scope)
   at IronPython.Hosting.PythonCommandLine.<>c__DisplayClass1.<RunOneInteraction>b__0()
ValueError: An item with the same key has already been added.

My guess would be that the debuggable lambda re-writer isn't handling re-use of the same 
parameter within different blocks.  It might be possible to change this from calling Insert into
using the indexer to assign (which allows replacements) but that's probably not the correct fix.

Can you open a bug?  I can look into it more later.

> -----Original Message-----
> From: ironpython-users-bounces+dinov=microsoft.com at python.org
> [mailto:ironpython-users-bounces+dinov=microsoft.com at python.org] On
> Behalf Of Markus Schaber
> Sent: Wednesday, August 24, 2011 4:41 AM
> To: Discussion of IronPython
> Subject: [Ironpython-users] ValueError in IronPython 2.7.1 beta
> Hi,
> I still have the problem with the ValueError in IronPython 2.7.1 beta.
> I now managed to cut down the test case to a single file with just a few lines,
> and I can also reproduce it when executing it in the ipy.exe interactive
> interpreter:
> -- snip --
> import os, sys
> def trace_handler(a,b,c):
>     return trace_handler
> sys.settrace(trace_handler)
> for root, dirs, files in os.walk("."):
>     pass
> -- snap --
> Traceback (most recent call last):
>   File "test.py", line 8, in <module>
> ValueError: Ein Element mit dem gleichen Schlüssel wurde bereits
> hinzugefügt.
> Any ideas? Or is everyone out in summer holidays? :-)
> Best regards
> Markus Schaber
> ___________________________
> We software Automation.
> 3S-Smart Software Solutions GmbH
> Markus Schaber | Developer
> Memminger Str. 151 | 87439 Kempten | Germany | Tel. +49-831-54031-0 |
> Fax +49-831-54031-50
> Email: m.schaber at 3s-software.com | Web: http://www.3s-software.com
> CoDeSys internet forum: http://forum.3s-software.com Download CoDeSys
> sample projects: http://www.3s-
> software.com/index.shtml?sample_projects
> Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner | Trade
> register: Kempten HRB 6186 | Tax ID No.: DE 167014915
> _______________________________________________
> Ironpython-users mailing list
> Ironpython-users at python.org
> http://mail.python.org/mailman/listinfo/ironpython-users

More information about the Ironpython-users mailing list