This is an old copy of the Python FAQ. The information here may be outdated.

PyRun_SimpleFile() crashes on Windows but not on Unix; why?

PyRun_SimpleFile takes a pointer to a stdio FILE structure, but the contents of that structure is not standardized. If the FILE* structure in your embedding program isn’t the same as is assumed by the Python interpreter it won’t work, and your program may crash.

This is very sensitive to the compiler vendor, version and (perhaps) even compilation options.

The Python 1.5 DLLs (python15.dll) are all compiled with MSVC 5 and with multithreading-DLL options (/MD). Python 2.1-2.3 uses MSVC 6, and Python 2.4 and 2.5 uses MSVC 7.

If you can’t change compilers or flags, try using PyRun_SimpleString. A trick to get it to run an arbitrary file is to construct a call to execfile with the name of your file as argument.

Also note that you can’t mix-and-match Debug and Release versions. If you wish to use the Debug Multithreaded DLL, then your module must have an “_d” appended to the base name.

CATEGORY: windows

 

A Django site. rendered by a django application. hosted by webfaction.