Author: mattip <matti.pi...@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
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to