[Python.NET] Problem when chaining script calls through CLR classes

Brian Lloyd brian at zope.com
Thu Jan 20 21:23:52 CET 2005


> So is this issue a bug, or should I simply not be doing what I'm doing?

Hi Chris - 

Certainly what you're trying to do is intended to work - I'll 
have to do some digging to find out why its not.

Thanks for the clear test case, BTW ;)

Brian Lloyd        brian at zope.com
V.P. Engineering   540.361.1716              
Zope Corporation   http://www.zope.com 


> -----Original Message-----
> From: pythondotnet-bounces at python.org
> [mailto:pythondotnet-bounces at python.org]On Behalf Of Chris Faulhaber
> Sent: Saturday, January 15, 2005 7:21 PM
> To: pythondotnet at python.org
> Subject: [Python.NET] Problem when chaining script calls through CLR
> classes
> 
> 
> 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 at python.org
> http://mail.python.org/mailman/listinfo/pythondotnet
> 


More information about the PythonDotNet mailing list