Using python *.py files like DLL...
Sebastien Auclair
sxa at fluent.com
Mon Dec 9 17:01:44 EST 2002
Hi folks !
We are porting a C++ software from Linux to Win2000.
Our software can load modules implemented in either DLL (.so on Linux) or
PYTHON files. (*.py).
The problem is that we just discovered that our strategy for loading python
files doesn't work under Win2000.
We were using this call sequence :
FILE* fd = fopen(fname,"r"); // fname... for instance "moduleABC.py"
struct _node* nd = PyParser_SimpleParseFile( fd, fname, Py_file_input );
PyObject* code = (PyObject*)PyNode_Compile( nd, fname );
PyObject* module = PyImport_ExecCodeModule( const_cast<char*>(name),
code );
Py_INCREF( module );
This is the equivalent of LoadLibrary for dll cases.
This code works fine under Linux but there's maybe a bug with the WIN32
version.
PyParser_SimpleParseFile causes a :
"Unhandled exception in TOTO.exe (NTDLL.DLL): 0xC0000005: ACCESS
VIOLATION."
In all cases, we need an alternative !!! How can we create PyObject from
PYTHON source contained in a regular *.py file ?
SETUP:
WIN2000
PYTHON 2.2.2
VC++ 6.0
debug and release versions produces the same result.
Thanks for any help.
___________________________________________
Seb
More information about the Python-list
mailing list