En Tue, 30 Jun 2009 13:05:42 -0300, Jérôme Fuselier <jerome.fusel...@gmail.com> escribió:
I've tried to import a script in an embedded python intrepreter but this script fails when it imports the uuid module. I have a segmentation fault in Py_Finalize(). #include "Python.h" void test() { Py_Initialize(); PyImport_Import(PyString_FromString("uuid")); Py_Finalize(); } main(int argc, char **argv) { for (i=0 ; i < 10; i++) test(); } For my application, I have to call Py_initialize and Py_Finalize several times so factorizing them in the main function is not an easy solution for me.
Are you sure you can't do that? Not even using Py_IsInitialized? Try to avoid repeatedly calling Py_Initialize - won't work. Python 2.x does not have a way to "un-initialize" an extension module (that's a big flaw in Python design). Modules that contain global state are likely to crash the interpreter when used by the second time. (Python 3 attempts to fix that) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list