[pypy-commit] pypy default: prevent opening error dialog box on windows when not using testrunner/runner
mattip
noreply at buildbot.pypy.org
Wed Jun 11 22:42:17 CEST 2014
Author: mattip <matti.picus at gmail.com>
Branch:
Changeset: r72020:8493b2b0a91b
Date: 2014-06-11 20:57 +0300
http://bitbucket.org/pypy/pypy/changeset/8493b2b0a91b/
Log: prevent opening error dialog box on windows when not using
testrunner/runner
diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -313,8 +313,25 @@
def cmdexec(self, args='', env=None, err=False, expect_crash=False):
assert self._compiled
+ if expect_crash and sys.platform == 'win32':
+ #Prevent opening a dialog box
+ import ctypes
+ winapi = ctypes.windll.kernel32
+ SetErrorMode = winapi.SetErrorMode
+ SetErrorMode.argtypes=[ctypes.c_int]
+
+ SEM_FAILCRITICALERRORS = 1
+ SEM_NOGPFAULTERRORBOX = 2
+ SEM_NOOPENFILEERRORBOX = 0x8000
+ flags = SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX \
+ | SEM_NOOPENFILEERRORBOX
+ #Since there is no GetErrorMode, do a double Set
+ old_mode = SetErrorMode(flags)
+ SetErrorMode(old_mode | flags)
res = self.translator.platform.execute(self.executable_name, args,
env=env)
+ if expect_crash and sys.platform == 'win32':
+ SetErrorMode(old_mode)
if res.returncode != 0:
if expect_crash:
return res.out, res.err
More information about the pypy-commit
mailing list