Py_Finalize Crashes in after PyRun_File

Jon Kåre Hellan Jon.Kare.hellan at uninett.no
Fri Oct 4 05:07:34 EDT 2002


mrunalinikulkarni at yahoo.com (mk) writes:

> I run a python script which contains objects of classes declared in an
> extension module.
> 
> the code that i use to execute the script file is as follows-
> 
> if (!Py_IsInitialized()) Py_Initialize();
..
> 	Py_Finalize();
> 
> This code gets executed from a menu item click of my VC++ 6.0
> application. the first time i execute it the script gets executed
> fine. but the second time i execute the code it crashes at PyRun_File
> statement. This does not happen if i comment Py_Finalize in the above
> code. Then the code can be executed repetitively without a crash.

You don't say, but my guess is that Py_Initialize is a static
variable. Changing it to FALSE when you call Py_Finalize probably
fixes this. On the other hand, do you really need Py_Finalize?

Regards

Jon Kåre



More information about the Python-list mailing list