Index: PC/msvcrtmodule.c =================================================================== --- PC/msvcrtmodule.c (revision 69093) +++ PC/msvcrtmodule.c (working copy) @@ -27,6 +27,7 @@ #include #endif #endif +#include // Force the malloc heap to clean itself up, and free unused blocks // back to the OS. (According to the docs, only works on NT.) @@ -279,7 +280,19 @@ } } +// CRT assertion handling and reporting functions. +static PyObject * +msvcrt_CrtSetReportMode(PyObject *self, PyObject *args) +{ + int reportType, reportMode; + if (!PyArg_ParseTuple(args, "ii:CrtSetReportMode", + &reportType, &reportMode)) + return NULL; + + return PyInt_FromLong(_CrtSetReportMode(reportType, reportMode)); +} + /* List of functions exported by this module */ static struct PyMethodDef msvcrt_functions[] = { {"heapmin", msvcrt_heapmin, METH_VARARGS}, @@ -298,6 +311,7 @@ {"putwch", msvcrt_putwch, METH_VARARGS}, {"ungetwch", msvcrt_ungetwch, METH_VARARGS}, #endif + {"CrtSetReportMode", msvcrt_CrtSetReportMode, METH_VARARGS}, {NULL, NULL} }; @@ -334,4 +348,13 @@ __LIBRARIES_ASSEMBLY_NAME_PREFIX); if (st < 0)return; #endif + // _CrtSetReportMode() constants + insertint(d, "_CRT_WARN", _CRT_WARN); + insertint(d, "_CRT_ERROR", _CRT_ERROR); + insertint(d, "_CRT_ASSERT", _CRT_ASSERT); + + insertint(d, "_CRTDBG_MODE_DEBUG", _CRTDBG_MODE_DEBUG); + insertint(d, "_CRTDBG_MODE_FILE", _CRTDBG_MODE_FILE); + insertint(d, "_CRTDBG_MODE_WNDW", _CRTDBG_MODE_WNDW); + insertint(d, "_CRTDBG_REPORT_MODE", _CRTDBG_REPORT_MODE); }