How to reload a module in embedded C
Emmanuel Astier
emmanuel.astier at winwise.fr
Fri Jun 22 13:41:49 EDT 2001
Hi,
I would like to reload a module, AND the module that are used in this
module.
If there's a
"import Camera"
in my first module, I would like to reimport the Camera module also.
I first tried :
modTemp = PyImport_ReloadModule( Module );
// Initialisation et verification de Python :
if ( modTemp )
{
Module = modTemp;
Py_XDECREF ( modTemp );
mdict = PyModule_GetDict( Module );
EntryPoint = PyDict_GetItemString(mdict, "Tick"); /* borrowed
reference */
if ( EntryPoint )
{
if ( PyCallable_Check( EntryPoint ) )
{
IsCompileOk = true;
}
}
else
{
Py_XDECREF ( Module );
}
}
else
{
CompileErrorPrint();
LoadModule();
}
But that doesn't reload the dependent modules.
So I tried to 'del' my first module, but it crashes ( Python thinks
the module is still there ) with :
IsCompileOk = false;
PyObject_Del( Module );
Module = NULL;
// Initialisation et verification de Python :
LoadModule();
So I don't know how to do...
Any idea ??
Thanks by advance,
Emmanuel
More information about the Python-list
mailing list