Embedding Pythonwin - Python reports Fatal Error

Mark Hammond MarkH at ActiveState.com
Fri Sep 22 22:21:01 EDT 2000


> I have been following the documentation at
> http://www.python.org/windows/pythonwin/EmbeddingWin32ui.html

This is out of date WRT threads - full support for threading was added
before this doc.

> Everything compiles nicely, but when I call
> Win32uiHostGlue::DynamicApplicationInit() the application crashes
with
> the message "Fatal Python error: Can not setup interpreter state, as
> current state is invalid" in the trace window.
>
> Further investigation reveals that this error occurs on the line in
> Win32uiHostGlue.h that reads:
>
> rc = (*pfnInit)(this, (char *)cmd, additionalPaths);

There is no such line in the latest version.  You definately should be
running from the CVS version of the sources - that looks fairly old
(well, pre changes for 1.6 and later anyway)

Also, it appears you can not bee "below" the pfnInit call - ie, there
is no source available.  This implies a debug/release mismatch - eg,
that you have a debug application, but a release win32ui, for example.
Although win32uiHostGlue.h is supposed to catch that, it may not.

All the pfn's used in this module are entry points into either
pythonxx(_d).dll or win32ui(_d).pyd - so you should be able to step
into each of them.  In this case, the error will come from either
pythonxx_d.dll or pywintypesxx_d.dll - if you are seeing non _d
versions, fix that first!

Finally, pythonwin.cpp is a very small program, and uses this exact
same technique to boot Pythonwin.  Thus, it is good sample code for
this purpose - what is different between your app and Pythonwin.cpp?
Does your built pythonwin.exe work?

Mark.





More information about the Python-list mailing list