I'm upgrading IronPython 2 from B4 to B5 and one of my unit tests is
aborting with InvalidProgramException exception in
Microsoft.Scripting.Actions.MatchCaller.Call6.
The problem occurs if in the Python statements I try to import anything, no
matter what.
No import statement, no error. Also, when executed directly, without a unit
test, the same code runs correctly.
Is this a bug?
Source code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting;
namespace HelloDLRWorld
{
[TestFixture]
public class DlrTest
{
[Test]
public void ImportTest()
{
ScriptRuntimeSetup srs = ScriptRuntimeSetup.ReadConfiguration();
ScriptRuntime runtime = new ScriptRuntime(srs);
runtime.LoadAssembly(typeof(System.Diagnostics.Debug).Assembly);
runtime.LoadAssembly(typeof(System.Double).Assembly);
ScriptEngine pyEng = runtime.GetEngine("IronPython");
ScriptSource source = pyEng.CreateScriptSourceFromString(@"
import System.Diagnostics
output='hello world from DLR/IronPython'
System.Diagnostics.Debug.WriteLine(output)
", SourceCodeKind.Statements);
ScriptScope scope = pyEng.CreateScope();
source.Execute(scope);
object outputMsg = scope.GetVariable("output");
Assert.AreEqual("hello world from DLR/IronPython",
outputMsg.ToString());
}
}
}
Test result:
------ Test started: Assembly: HelloDLRWorld.exe ------
TestCase 'HelloDLRWorld.DlrTest.ImportTest'
failed: System.InvalidProgramException : Common Language Runtime detectou um
programa inválido.
em
Microsoft.Scripting.Actions.MatchCaller.Call6[T0,T1,T2,T3,T4,T5,TRet](Func`8
target, CallSite site, Object[] args)
em Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[]
args)
em
Microsoft.Scripting.Actions.UpdateDelegates.Update6[T,T0,T1,T2,T3,T4,T5,TRet](CallSite
site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
em IronPython.Runtime.Importer.Import(CodeContext context, String
fullName, PythonTuple from, Int32 level)
em IronPython.Runtime.Operations.PythonOps.ImportTop(CodeContext
context, String fullName, Int32 level)
em <module>$1##1(Closure , Scope , LanguageContext )
em
Microsoft.Scripting.Runtime.OptimizedScriptCode.InvokeTarget(LambdaExpression
code, Scope scope)
em Microsoft.Scripting.ScriptCode.Run(Scope scope)
em Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink
errorSink)
em Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
C:\Temp\HelloDLRWorld\HelloDLRWorld\HelloDLRWorld\DlrTest.cs(28,0): em
HelloDLRWorld.DlrTest.ImportTest()
0 passed, 1 failed, 0 skipped, took 6,47 seconds.
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com