[IronPython] TypeError: expected Tuple, got tuple

Jeff Hardy jdhardy at gmail.com
Sun Nov 25 10:01:51 CET 2007


Hi Dino,
Thanks for the explanation. You guys may want to consider renaming
some things, though, because there's a List instead of PythonList, and
that's what threw me off. I expected Tuple to work as well. I suspect
it will be less of an issue once the new API is in and there are some
docs for all of this. The joys of working with alpha software :).

-Jeff

On Nov 24, 2007 1:52 PM, Dino Viehland <dinov at exchange.microsoft.com> wrote:
> They're actually two rather distinct data types and there's no plans to merge them right now.  Tuple is used for creating strongly-typed fixed-sized collections and is used internally by the DLR.  We use it for creating our FunctionEnvironment's (for closures), for creating storage which back modules in collectible form, and in a couple of other places.  Basically it's a faster alternative to an array.  And of course PythonTuple is just Python's standard tuple type.
>
> ________________________________________
> From: users-bounces at lists.ironpython.com [users-bounces at lists.ironpython.com] On Behalf Of Jeff Hardy [jdhardy at gmail.com]
> Sent: Wednesday, November 21, 2007 7:12 PM
> To: Discussion of IronPython
> Subject: Re: [IronPython] TypeError: expected Tuple, got tuple
>
>
> Hi,
> Well, I found (or rather rediscovered :)) PythonTuple, but I'm still
> curious as to whether they will be unified in the future.
>
> -Jeff
>
> On Nov 21, 2007 7:00 PM, Jeff Hardy <jdhardy at gmail.com> wrote:
> > Hi,
> > If I have the following C# library:
> > nunified in the futureamespace TestLib
> > {
> >    public class Foo
> >    {
> >        public string Bar(Microsoft.Scripting.Tuple t)
> >        {
> >            return t.ToString();
> >        }
> >    }
> > }
> >
> > Calling Bar from IronPython results in "TypeError: expected Tuple, got
> > tuple". Why are the Python tuple and Microsoft.Scripting.Tuple
> > different? And what is the proper type to use for Python tuples?
> >
> > -Jeff
> >
> > Python code:
> > IronPython console: IronPython 2.0A6 (2.0.11102.00) on .NET 2.0.50727.312
> > Copyright (c) Microsoft Corporation. All rights reserved.
> > >>> import clr
> > >>> clr.AddReference("TestLib")
> > >>> import TestLib
> > >>> TestLib.Foo().Bar((1, 2, 3))
> > Traceback (most recent call last):
> >  File , line 0, in ##235
> > TypeError: expected Tuple, got tuple
> >
> >
> > With -X:ExceptionDetail:
> > IronPython console: IronPython 2.0A6 (2.0.11102.00) on .NET 2.0.50727.312
> > Copyright (c) Microsoft Corporation. All rights reserved.
> > >>> import clr
> > >>> clr.AddReference("TestLib")
> > >>> import TestLib
> > >>> TestLib.Foo().Bar((1, 2, 3))
> > expected Tuple, got tuple
> >   at IronPython.Runtime.Converter.Convert(Object value, Type to)
> >   at IronPython.Runtime.Converter.ConvertToReferenceType(Object fromObject, Run
> > timeTypeHandle typeHandle)
> >   at Microsoft.Scripting.Utils.InvokeHelper`3.Invoke(Object arg0, Object arg1)
> >   at Microsoft.Scripting.Utils.ReflectedCaller.Invoke(Object[] args)
> >   at Microsoft.Scripting.Ast.MethodCallExpression.InvokeMethod(Object instance,
> >  Object[] parameters)
> >   at Microsoft.Scripting.Ast.MethodCallExpression.DoEvaluate(CodeContext contex
> > t)
> >   at Microsoft.Scripting.Ast.UnaryExpression.DoEvaluate(CodeContext context)
> >   at Microsoft.Scripting.Ast.ConditionalExpression.DoEvaluate(CodeContext conte
> > xt)
> >   at Microsoft.Scripting.Ast.MethodCallExpression.DoEvaluate(CodeContext contex
> > t)
> >   at Microsoft.Scripting.Ast.ReturnStatement.DoExecute(CodeContext context)
> >   at Microsoft.Scripting.Ast.Statement.Execute(CodeContext context)
> >   at Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeConte
> > xt callerContext, DynamicAction action, Object[] args, Object site, T& target, R
> > uleSet`1& rules)
> >   at Microsoft.Scripting.Actions.DynamicSite`3.UpdateBindingAndInvoke(CodeConte
> > xt context, T0 arg0, T1 arg1)
> >   at Microsoft.Scripting.Actions.DynamicSiteHelpers.UninitializedTargetHelper`7
> > .Invoke2(DynamicSite`3 site, CodeContext context, T0 arg0, T1 arg1)
> >   at Microsoft.Scripting.Actions.DynamicSite`3.Invoke(CodeContext context, T0 a
> > rg0, T1 arg1)
> >   at ##235(Object[] , CodeContext )
> >   at Microsoft.Scripting.ScriptCode.Run(CodeContext codeContext, Boolean tryEva
> > luate)
> >   at Microsoft.Scripting.ScriptCode.Run(ScriptModule module)
> >   at Microsoft.Scripting.Hosting.CompiledCode.Evaluate(IScriptModule module)
> >   at Microsoft.Scripting.Hosting.ScriptEngine.ExecuteCommand(String code, IScri
> > ptModule module)
> >   at Microsoft.Scripting.Shell.CommandLine.RunOneInteraction()
> >   at Microsoft.Scripting.Shell.CommandLine.TryInteractiveAction()
> >   at IronPython.Hosting.PythonCommandLine.TryInteractiveAction()
> >   at Microsoft.Scripting.Shell.CommandLine.RunInteractiveLoop()
> > TypeError: expected Tuple, got tuple
> >
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>



More information about the Ironpython-users mailing list