Message292594
I have just tried to do this task using xml.etree.ElementTree and still have the same problem.
In the file 'write_to_xml1.py' I'm trying to develop some function that creates an xml file and then add data containing non ascii characters.The python program works perfectly, but when I tried to call these functions from C, the program crashes.Note that this problem dosn't happen when adding ascii characters only.Here is the C program :
void create_report()
{
PyObject *pName, *pModule, *pDict, *pFunc, *pValue, *pArgs;
// Initialize the Python Interpreter
Py_Initialize();
// Build the name object
pName = PyString_FromString("write_to_xml1");
// Load the module object
pModule = PyImport_Import(pName);
// pDict is a borrowed reference
pDict = PyModule_GetDict(pModule);
// pFunc is also a borrowed reference
pFunc = PyDict_GetItemString(pDict,"create_report");
if (PyCallable_Check(pFunc))
{
PyObject_CallObject(pFunc,NULL);
} else
{
PyErr_Print();
}
}
void modif_report()
{
PyObject *pName, *pModule, *pDict, *pFunc, *pValue, *pArgs;
// Initialize the Python Interpreter
Py_Initialize();
// Build the name object
pName = PyString_FromString("write_to_xml1");
// Load the module object
pModule = PyImport_Import(pName);
// pDict is a borrowed reference
pDict = PyModule_GetDict(pModule);
// pFunc is also a borrowed reference
pFunc = PyDict_GetItemString(pDict,"traite");
if (PyCallable_Check(pFunc))
{
PyObject_CallObject(pFunc,NULL);
} else
{
PyErr_Print();
}
}
int main(int argc, char *argv[])
{
create_report();
modif_report();
return(0);
} // end main() |
|
Date |
User |
Action |
Args |
2017-04-29 14:16:06 | aimad | set | recipients:
+ aimad, lemburg, vstinner, benjamin.peterson, ezio.melotti, serhiy.storchaka |
2017-04-29 14:16:06 | aimad | set | messageid: <1493475366.41.0.0930760044083.issue30195@psf.upfronthosting.co.za> |
2017-04-29 14:16:06 | aimad | link | issue30195 messages |
2017-04-29 14:16:06 | aimad | create | |
|