[python-win32] Loading C extensions in Python 2.6/2.7 from classic ASP

Mark Hammond mhammond at skippinet.com.au
Sun Sep 11 21:42:44 CEST 2011


On 11/09/2011 9:20 AM, Chris Lambacher wrote:
> On Sun, Sep 11, 2011 at 11:57 AM, Chris Lambacher
> <chris at kateandchris.net>  wrote:
>>>
>>> If so, that surprises me.  To get as far as you did, much of the pywin32
>>> framework was imported, so all those modules must have imported OK.
>>
>> I don't know why the imported pyd files are not picking up the version
>> from pythoncomloader26.dll, but I got the idea to stop removing msvcrt
>> from the manifest from this stack overflow post:
>> http://stackoverflow.com/questions/3706293/why-do-no-python-dlls-built-with-msvc-load-with-mod-wsgi
>>
>> and ended up at these python bugs as the source of the current state of things:
>> http://bugs.python.org/issue4120
>> http://bugs.python.org/issue4566
>>
>> Assuming that the fix from bug 4566 has been applied also to
>> pythoncomloader26.dll perhaps there is some other kind of interaction
>> on Windows 7 x64? I do have a Windows Vista x32 machine I could test
>> on. Is it also possible that I am missing some dependency like the
>> exact version of msvcr90.dll that is used with the pywin32 build?

I doubt it - I believe pywin32 is loading and working fine - otherwise 
we would not get as far as the previous error you reported:

"""
Traceback (most recent call last): File "<Script Block >", line 3, in
<module> import lxml.etree ImportError: DLL load failed: The specified
module could not be found.
"""

> Further investigation gets me to:
> http://omnicognate.wordpress.com/2009/10/05/winsxs/
>
> In the section called "Creation and Activation of Activation Contexts
> by Inline Helpers in the Platform SDK Headers" they enumerate a
> potential way we loose the Activation Context. Is
> pythoncomloader26.dll protecting itself against that?

Yeah - the steps in that article are exactly what Pythonxx.dll and 
pycomloaderxx.dll are taking.

The best I can suggest is to make a small .asp example which requires 
nothing beyond pywin32 - eg, some of the asp samples.  Once you are 
convinced that works, I'd start looking into what is different about the 
lxml.etree module - I suspect you will find that module references the 
CRT assembly.

Unfortunately, it seems there is some significant difference to a 
.pyd/.dll having a manifest (even without a reference to the CRT) versus 
no manifest at all - but sadly the details escape me at the moment.  But 
for example, the pywin32 modules winxpgui and winxptheme both have a 
manifest which doesn't reference the CRT, and those module fail to load 
in some contexts (I guess they will fail to load in ASP too).  Sadly 
they *need* a manifest, so the next pywin32 build will probably link the 
CRT statically for those files) - but it also might be worth 
experimenting with those too - eg, I suspect a sample ASP module will 
fail to work as soon as you attempt to import winxpgui.

Mark


More information about the python-win32 mailing list