Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   problem with embedding python 2.3 and importing win32 extensions (http://www.velocityreviews.com/forums/t328182-problem-with-embedding-python-2-3-and-importing-win32-extensions.html)

Axel Diener 02-11-2004 07:14 AM

problem with embedding python 2.3 and importing win32 extensions
 
I embed python interpreters in a C++ program.
For each script to execute I create a new interpreter.
In this environment I can use the win32 extensions only one time.
Here is a little piece of code to illustrate the problem:

int
main(int argc, char **argv)
{
Py_Initialize();
Py_SetProgramName(argv[0]);

PyThreadState *save_tstate=PyThreadState_Swap(NULL);
PyThreadState *state=Py_NewInterpreter();

int rc=PyRun_SimpleString("import pywintypes;import pythoncom");
//this works well
printf("%d\n",rc);

Py_EndInterpreter(state);

PyThreadState_Swap(save_tstate);

state=Py_NewInterpreter();

rc=PyRun_SimpleString("import pywintypes;import pythoncom");
//this and all further atemps will fail
printf("%d\n",rc);

Py_EndInterpreter(state);
PyThreadState_Swap(save_tstate);

Py_Finalize();
}

Here is the output auf this little program:

0
Traceback (most recent call last):
File "<string>", line 1, in ?
File "C:\uti\Python23\Lib\site-packages\pythoncom.py", line 3, in ?
pywintypes.__import_pywin32_system_module__("pytho ncom", globals())
File "C:\uti\Python23\Lib\site-packages\win32\lib\pywintypes.py", line
9, in _
_import_pywin32_system_module__
import imp, sys, os
TypeError: 'NoneType' object is not callable
-1

I use

Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)] on win32

with

pywin32-200.win32-py2.3.exe
(same result for win32all-163)

The problem doesn't occur with Python 2.2 and win32all-157 due to different
import wrappers.

Is there any way to overcome this problem?

Thanks
Axel Diener


All times are GMT. The time now is 11:22 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.