Bonjour,

j'ai un programme C++ (sous VS2010) qui appel un script python.

le problème est que lorsque j’exécute mon script plus d'une fois dans mon programme C++ j'ai le message d'erreur suivant :

*********************************
Assertion failed !

Program: ...
File : libs\python\src\converter\registry.cpp
Line: 212

Expression: slot->m_to_python == 0
********************************

Si je le lance 1 seule fois ça marche bien, mais si je le relance il me stop le programme.

j'ai peut-être un problème de libération de la mémoire quand j'appelle le script ?

voici ma fonction C++ pour appeler le script Python, où fctName représente le nom de la fonction Python que je souhaite lancer à partir du script :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
 
void UlisBoost::LaunchScript(char * fctName)
{
	using namespace std;
	PyObject *pName, *pModule, *pDict, *pFunc;
 
    // Initialize the Python Interpreter
    Py_Initialize();
 
    // Build the name object
    pName = PyString_FromString("scriptBoost");
	if(pName == NULL) 
	{
		cout<< "error" << endl;
	}
 
    // Load the module object
    pModule = PyImport_Import(pName);
	if(pName == NULL) 
	{
		cout<< "pModule" << endl;
	}
 
    // pDict is a borrowed reference 
    pDict = PyModule_GetDict(pModule);
	if(pDict == NULL) 
	{
		cout<< "erreur du Dico" << endl;
	}
 
	// pFunc is also a borrowed reference 
    pFunc = PyDict_GetItemString(pDict, fctName);
	if(pFunc == NULL) 
	{
		cout<< "erreur fonction test" << endl;
	}
 
    if (PyCallable_Check(pFunc)) 
	{
		cout << "********  Lancement de la fonction Python ********" << endl;
		PyObject_CallFunction(pFunc, NULL);
	}
	else 
        PyErr_Print();
 
    // Clean up
    Py_DECREF(pModule);
    Py_DECREF(pName);
 
 
	// Finalize the Python Interpreter
    Py_Finalize();
	cout << "********     Fin du script Python    ********" << endl;
}
Si quelqu'un a une idée

merci d'avance