[issue24429] msvcrt error when embedded

erik flister report at bugs.python.org
Sat Jun 13 20:15:15 CEST 2015


erik flister added the comment:

> About the only possible solution here would be to special case ctypes to detect msvcr90 as a parameter (later versions of the CRT don't need it) and also whether another activation context already exists. We could also document the need for a complete manifest in the embedding docs. 

i'm not following why it's a special case, or why later versions wouldn't have the same problem?  isn't this a problem for any DLLs that the embedding context may have loaded that would conflict with DLLs that python depends on?  python's DLL already has the necessary "complete manifest," right?  as long as CDLL does the proper context manipulations, client code shouldn't have to worry about whether it's running embedded, right?  

what is the purpose of ctypes.cdll.msvcrt if no one is supposed to use it?  there is also "import msvcrt" which is apparently a subset of what you get from find_library('c'), so would need the same fix?

> All of this really only affects 2.7, as later versions of Python don't necessarily suffer the same limitation (unless someone wants to load msvcr90 explicitly).

what changed that avoids the problem?  perhaps that fix can be applied to 2.7?

> What functionality do you need that you can't get some other way (such as the msvcrt module)? Or is it just the uuid issue?

innocent ol' me was just trying to import shapely from matlab - they call find_library('c') and need the 'free' function.  i don't think they ever malloc -- they depend on a geos_c.dll, which must do the allocations and is built on whatever msvcrt was used for python?  probably a better design would be for geos_c.dll to export its own free function?  but afaiu, geos_c.dll comes from a totally different (more legacy?) project, not python related...  shapely is a dependency of the library i actually need, which also uses uuid.  uuid is the only case i can find in the standard libraries that also calls find_library('c').  manually changing those calls allowed me to successfully import everything from matlab.  ctypes and distutils also mention msvc* a lot, obviously...  getpass.py and multiprocessing and subprocess use "import msvcrt".

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24429>
_______________________________________


More information about the Python-bugs-list mailing list