[IronPython] list -> Array conversion in Beta 8
Milman, Seth
Seth_Milman at bose.com
Fri Jun 30 21:03:29 CEST 2006
Hi,
I just upgraded from Beta 7 to Beta 8 and I'm having a problem passing
runtime lists to assembly functions that expect an array. In beta 7,
the list went through function
IronPython.Runtime.Converter.TryConvertToArray. In beta 8, it is passed
to IronPython.Runtime.NewConverter.ConvertToArray.
Beta 7 seemed to work, Beta 8 doesn't. Is this new behavior by design?
If so, how should I work around it?
Here is a repro:
// C# Code
Namespace mySpace {
public class myClass {
public static double SumArray( System.Double[] a ) {
double sum = 0.0;
foreach( double d in a ) {
sum += d;
}
return sum;
}
}
}
# Python code
...
L = [1.0, 2.0, 3.0]
print myClass.SumArray( L )
In beta 7 it works.
In beta 8, I get this exception trace:
expected array_float, found list
at IronPython.Runtime.NewConverter.ConvertToArray(Object value, Type
to) in C
:\source\VnV~sm15019\VnV\Automation\IronPython-1.0-Beta8\Src\IronPython\
Runtime\
Converter.cs:line 527
at IronPython.Runtime.NewConverter.Convert(Object value, Type toType)
in C:\s
ource\VnV~sm15019\VnV\Automation\IronPython-1.0-Beta8\Src\IronPython\Run
time\Con
verter.cs:line 599
at IronPython.Runtime.NewConverter.ConvertToReferenceType(Object
fromObject,
RuntimeTypeHandle typeHandle) in
C:\source\VnV~sm15019\VnV\Automation\IronPython
-1.0-Beta8\Src\IronPython\Runtime\Converter.cs:line 408
at StaticSumArray##15(Object )
at IronPython.Runtime.Calls.CallTarget1.Invoke(Object arg0)
at IronPython.Runtime.Calls.FastCallable1.Call(ICallerContext
context, Object
arg0) in
c:\source\VnV~sm15019\VnV\Automation\IronPython-1.0-Beta8\Src\IronPyth
on\Runtime\Calls\FastCallable.Generated.cs:line 434
at IronPython.Runtime.Calls.BuiltinFunction.Call(ICallerContext
context, Obje
ct arg0) in
c:\source\VnV~sm15019\VnV\Automation\IronPython-1.0-Beta8\Src\IronPy
thon\Runtime\Calls\BuiltinFunction.Generated.cs:line 32
at IronPython.Runtime.Operations.Ops.CallWithContext(ICallerContext
context,
Object func, Object arg0) in
c:\source\VnV~sm15019\VnV\Automation\IronPython-1.0
-Beta8\Src\IronPython\Runtime\Operations\Ops.Generated.cs:line 85
at <stdin>##14(ModuleScope )
at IronPython.Runtime.CompiledCodeDelegate.Invoke(ModuleScope
moduleScope)
at IronPython.Runtime.CompiledCode.Run(ModuleScope moduleScope) in
c:\source\
VnV~sm15019\VnV\Automation\IronPython-1.0-Beta8\Src\IronPython\Runtime\M
oduleSco
pe.cs:line 264
at IronPython.Hosting.PythonEngine.ExecuteToConsole(String text,
ModuleScope
defaultScope) in
c:\source\VnV~sm15019\VnV\Automation\IronPython-1.0-Beta8\Src\I
ronPython\Hosting\PythonEngine.cs:line 400
at IronPythonConsole.PythonCommandLine.DoOneInteractive(ModuleScope
topFrame)
in
C:\source\VnV~sm15019\VnV\Automation\IronPython-1.0-Beta8\Src\IronPython
Cons
ole\PythonCommandLine.cs:line 491
at
IronPythonConsole.PythonCommandLine.<RunInteractiveLoop>b__6(Boolean&
cont
inueInteractionArgument) in
C:\source\VnV~sm15019\VnV\Automation\IronPython-1.0-
Beta8\Src\IronPythonConsole\PythonCommandLine.cs:line 631
at
IronPythonConsole.PythonCommandLine.TryInteractiveAction(InteractiveActi
on
interactiveAction, Boolean& continueInteraction) in
C:\source\VnV~sm15019\VnV\A
utomation\IronPython-1.0-Beta8\Src\IronPythonConsole\PythonCommandLine.c
s:line 5
41
TypeError: expected array_float, found list
Any suggestions?
Thanks,
Seth Milman
More information about the Ironpython-users
mailing list