[python-win32] Problem with msvcr90.dll
Mark Hammond
skippy.hammond at gmail.com
Wed Mar 2 23:25:55 CET 2011
On 2/02/2011 3:11 AM, Tefnet Developers wrote:
> Dnia 2011-02-01, wto o godzinie 10:44 +1100, Mark Hammond pisze:
>> This stuff is painful and poorly documented. Is it possible the code
>> which triggers the failing import is on a different thread than the one
>> which loaded Python? If so, I suspect the magic done by Python in
>> dl_nt.c may not be kicking in, which is supposed to ensure all python
>> modules are loaded using the "activation context" defined by pythonxx.dll.
>
> The smallest piece of program that shows the problem:
>
> $ cat pytest.c
> #include<Python.h>
>
>
> int main(void) {
> Py_Initialize();
> PyRun_SimpleString(
> "import traceback \n"
> "try:\n"
> " import pywintypes\n"
> "except:\n"
> " traceback.print_exc()\n"
> );
> }
>
> $ make pytest.exe
> i586-mingw32msvc-gcc -I./include -I./include/python -Wall -pedantic
> -std=c99 -c -o pytest.o pytest.c
>
> i586-mingw32msvc-gcc -L./lib -o pytest.exe pytest.o -lmingw32 -lpython26
> rm pytest.o
What happens if you give that executable a manifest referencing the CRT?
Note that things changed since pywin32 build 214 - now (almost) none
of the pywin32 pyd files have a manifest at all, meaning they can be
loaded correctly by Python itself in all cases - but the thing that
loads Python *must* have a manifest - ie, python.exe needs (and has)
one, as does the DLL which loads Python COM objects. It gets even more
complicated if Python is loaded via LoadLibrary - you can check the
source to pythoncomloader in the pywin32 repo for more details (the
short version is that the same hacks that Python itself does WRT
"activation contexts" needs to be done...)
Aahz's suggestion is a good one - you should use the VC compiler as your
"baseline", then try and get mingw going one you have initial success
with VC.
HTH,
Mark
More information about the python-win32
mailing list