BUG in python delegates returning int called from C#
hello, the following code may point to a bug in delegates implementation python: def stringFunc(): return "Hello world" def intFunc(): return 0 test.AnotherClass.SetStringDelegate (test.StringDelegate(stringFunc)) test.AnotherClass.SetIntDelegate (test.IntDelegate(intFunc)) t = test.MyClass() t.Dump(2) C#: public static void Dump () { Console.Out.WriteLine (stringDelegate() + " " + intDelegate()); } see output: [Debug]> python test.py Got : 2 Hello world 80098912 Hello world 80099400 [Debug]> --> As we see, the call to intDelegate() returns unspecified results...whereas it should return 0..... Full test case below. Stan. /* * Created by SharpDevelop. * User: hans * Date: 25/08/2005 * Time: 18:54 * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; namespace test { public delegate string StringDelegate(); public delegate int IntDelegate(); public class AnotherClass { static StringDelegate stringDelegate; static IntDelegate intDelegate; public static void SetStringDelegate (StringDelegate v) { stringDelegate = v; } public static void SetIntDelegate (IntDelegate v) { intDelegate = v; } public static void Dump () { Console.Out.WriteLine (stringDelegate() + " " + intDelegate()); } } /// <summary> /// Description of MyClass. /// </summary> public class MyClass { public void Dump (int v) { Console.Out.WriteLine ("Got : " + v); AnotherClass.Dump(); AnotherClass.Dump(); } } } from CLR.System.Reflection import Assembly Assembly.LoadWithPartialName("test") from CLR import test def stringFunc(): return "Hello world" def intFunc(): return 0 test.AnotherClass.SetStringDelegate (test.StringDelegate(stringFunc)) test.AnotherClass.SetIntDelegate (test.IntDelegate(intFunc)) t = test.MyClass() t.Dump(2)
participants (1)
-
Stan Pinte