diff -r 8c570828e4f0 PC/msvcrtmodule.c --- a/PC/msvcrtmodule.c Fri Nov 21 00:00:42 2008 +0900 +++ b/PC/msvcrtmodule.c Fri Nov 21 00:28:58 2008 +0900 @@ -21,6 +21,13 @@ #include #include #include + +#ifdef _MSC_VER +#if _MSC_VER >= 1500 +#define ADD_MSVCRT_MANIFEST_VERSIONS +#include +#endif +#endif // Force the malloc heap to clean itself up, and free unused blocks // back to the OS. (According to the docs, only works on NT.) @@ -273,6 +280,36 @@ } } +static int +insert_crt_version_info(PyObject *m) +{ + int st = 0; + +#ifdef ADD_MSVCRT_MANIFEST_VERSIONS + st = PyModule_AddStringConstant(m, "VC_ASSEMBLY_PUBLICKEYTOKEN", + _VC_ASSEMBLY_PUBLICKEYTOKEN); + if (st) { + PyErr_Clear(); + return -1; + } + + st = PyModule_AddStringConstant(m, "CRT_ASSEMBLY_VERSION", + _CRT_ASSEMBLY_VERSION); + if (st) { + PyErr_Clear(); + return -1; + } + + st = PyModule_AddStringConstant(m, "LIBRARIES_ASSEMBLY_NAME_PREFIX", + __LIBRARIES_ASSEMBLY_NAME_PREFIX); + if (st) { + PyErr_Clear(); + return -1; + } +#endif + + return st; +} /* List of functions exported by this module */ static struct PyMethodDef msvcrt_functions[] = { @@ -298,6 +335,7 @@ PyMODINIT_FUNC initmsvcrt(void) { + int st; PyObject *d; PyObject *m = Py_InitModule("msvcrt", msvcrt_functions); if (m == NULL) @@ -310,4 +348,12 @@ insertint(d, "LK_NBRLCK", _LK_NBRLCK); insertint(d, "LK_RLCK", _LK_RLCK); insertint(d, "LK_UNLCK", _LK_UNLCK); + + /* constants for the crt versions */ + st = insert_crt_version_info(m); + if (st) { + PyErr_SetString(PyExc_ImportError, "Error while adding crt " \ + "version strings constants"); + return; + } }