summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2007-08-30 14:57:25 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2007-08-30 14:57:25 (GMT)
commit945362cf971fb2e10f8f2a8e71e8ff10516ebe4c (patch)
tree3621d77cbecf1901cfa6baabf3e292e54aeb3e98
parentef0f129133eb0668879af219748dbe0e9242ee5d (diff)
downloadcpython-945362cf971fb2e10f8f2a8e71e8ff10516ebe4c.zip
cpython-945362cf971fb2e10f8f2a8e71e8ff10516ebe4c.tar.gz
cpython-945362cf971fb2e10f8f2a8e71e8ff10516ebe4c.tar.bz2
Implement PYTHONNOERRORWINDOW.
-rw-r--r--Modules/main.c24
-rw-r--r--Tools/buildbot/test.bat1
2 files changed, 25 insertions, 0 deletions
diff --git a/Modules/main.c b/Modules/main.c
index 4fb4d2d..e1e7b25 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -9,11 +9,16 @@
#endif
#if defined(MS_WINDOWS) || defined(__CYGWIN__)
+#include <windows.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#endif
+#ifdef _MSC_VER
+#include <crtdbg.h>
+#endif
+
#if (defined(PYOS_OS2) && !defined(PYCC_GCC)) || defined(MS_WINDOWS)
#define PYTHONHOMEHELP "<prefix>\\lib"
#else
@@ -323,6 +328,25 @@ Py_Main(int argc, char **argv)
(p = Py_GETENV("PYTHONUNBUFFERED")) && *p != '\0')
unbuffered = 1;
+#ifdef MS_WINDOWS
+ if ((p = Py_GETENV("PYTHONNOERRORWINDOW")) && *p != '\0') {
+ /* Disable all error windows created by the sytem
+ or the CRT. */
+#if defined(_DEBUG) && defined(_MSC_VER)
+ int types[] = {_CRT_WARN, _CRT_ERROR, _CRT_ASSERT};
+ int i;
+ for (i = 0; i < sizeof(types)/sizeof(types[0]); i++) {
+ _CrtSetReportFile(types[i], _CRTDBG_FILE_STDERR);
+ _CrtSetReportMode(types[i], _CRTDBG_MODE_FILE);
+ }
+ _set_error_mode(_OUT_TO_STDERR);
+#endif
+ SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |
+ SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
+ }
+#endif
+
+
if (command == NULL && module == NULL && _PyOS_optind < argc &&
strcmp(argv[_PyOS_optind], "-") != 0)
{
diff --git a/Tools/buildbot/test.bat b/Tools/buildbot/test.bat
index c8b1937..28456b3 100644
--- a/Tools/buildbot/test.bat
+++ b/Tools/buildbot/test.bat
@@ -1,3 +1,4 @@
@rem Used by the buildbot "test" step.
cd PCbuild
+set PYTHONNOERRORWINDOW=1
call rt.bat -d -q -uall -rw