Eryk Sun added the comment:
This is only a problem for ctypes when python27.dll is used in an application
that isn't manifested to load the "Microsoft.VC90.CRT" assembly. ctypes doesn't
have this problem for a regular script run via the 2.7 version of python.exe,
since the loader uses the python.exe activation context. Daniel claimed
otherwise, but his claim is demonstrably false. Maybe he was embedding Python.
Keno, I don't think it's a good idea to arbitrarily set the Python DLL's
activation context every time ctypes calls LoadLibrary. I proposed a more
generic solution in issue 24429, msg246754.
An alternative solution would be to implement a pure-Python activation context
class that works as a Python context manager. For example, it could create and
activate a context using the hModule and lpResourceName fields:
with ctypes.ACTCTX(module_handle=sys.dllhandle,
resource_name=2):
libc = ctypes.CDLL('msvcr90')
I have a Stack Overflow answer that demonstrates using activation contexts with
ctypes:
http://stackoverflow.com/a/27392347/205580
----------
nosy: +eryksun
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue17213>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com