Hi folks,
I've run across what I think may be a bug when I chain a script call through my own application. I'm using 1.0-beta4 on Windows XP with an installation of Python 2.4. The sequence I use to reproduce the problem is fairly simple:
1) Execute some Python code either through PyObject.InvokeMethod, or PythonEngine.RunSimpleString.
2) From the executed Python code, call into a CLR class.
3) From the CLR class, execute Python code again.
When this happens, I get a NullReferenceException with this stack trace:
at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw)
at Python.Runtime.PyObject.Invoke(PyObject[] args)
at Python.Runtime.PyObject.InvokeMethod(String name, PyObject[] args)
at <line in my code that made the second call into Python code>
Here is some example code that demonstrates the issue: using System; using Python.Runtime;
namespace PDNBug {
public class Example {
[STAThread]
static void Main(string[] args) {
PythonEngine.Initialize();
PythonEngine.RunSimpleString("from CLR.PDNBug import Example\nExample.FirstCall()");
}
public static void FirstCall () {
Console.WriteLine("First call succeeded.");
PythonEngine.RunSimpleString("from CLR.PDNBug import Example\nExample.SecondCall()");
}
public static void SecondCall () { Console.WriteLine("Second call succeeded."); } } }
Note that this example uses RunSimpleString to demonstrate the effect, but the above stack trace came from some more complex code that primarily uses code objects generated through Python compile(). When the example code is executed, I receive the following output:
First call succeeded.
Traceback (most recent call last):
File "<string>", line 2, in ?
<CLR.System.NullReferenceException object at 0x02DC6F50>: Object reference not set to an instance of an object.
So is this issue a bug, or should I simply not be doing what I'm doing?
Regards, Chris Faulhaber _________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet