[C++-sig] Py_Finalize() crashes when PyImport_Import() fails
Stefan Seefeld
seefeld at sympatico.ca
Mon Aug 25 04:31:42 CEST 2008
SrMandrake ElMago wrote:
>
> Exception exceptions.ImportError: 'No module named test_11' in
> 'garbage collection' ignored
> Fatal Python error: unexpected exception during garbage collection
The Python runtime may expect you to call handle Python exceptions
explicitely, prior to finalizing.
> if ( !pModule )
>
> {
>
If you got 0 here, Python has set an exception. Before moving on you
should handle it, for example by explicitely clearing it:
PyErr_Clear();
> std::cout << "Unable to open script " << s << std::endl;
>
> getchar ();
>
> }
>
>
>
> Py_XDECREF( pModule );
>
> Py_XDECREF( pName );
>
>
>
> Py_Finalize ();
>
With the above addition, the Python runtime should finalize fine.
HTH,
Stefan
--
...ich hab' noch einen Koffer in Berlin...
More information about the Cplusplus-sig
mailing list