[pypy-commit] pypy py3k: avoid segfault dialog box in packaging, copy pdb after translating (windows)

mattip noreply at buildbot.pypy.org
Fri Sep 19 13:43:26 CEST 2014


Author: mattip <matti.picus at gmail.com>
Branch: py3k
Changeset: r73613:047dc52c284f
Date: 2014-09-19 14:02 +0300
http://bitbucket.org/pypy/pypy/changeset/047dc52c284f/

Log:	avoid segfault dialog box in packaging, copy pdb after translating
	(windows)

diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py
--- a/pypy/tool/release/package.py
+++ b/pypy/tool/release/package.py
@@ -380,5 +380,21 @@
 
 if __name__ == '__main__':
     import sys
+    if sys.platform == 'win32':
+        # Try to avoid opeing a dialog box if one of the 
+        # subprocesses causes a system error
+        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)
+
     retval, _ = package(*sys.argv[1:])
     sys.exit(retval)
diff --git a/rpython/translator/driver.py b/rpython/translator/driver.py
--- a/rpython/translator/driver.py
+++ b/rpython/translator/driver.py
@@ -481,6 +481,14 @@
                     newlibname = newexename.new(basename=soname.basename)
                     shutil.copyfile(str(libname), str(newlibname.new(ext='lib')))
                     self.log.info("copied: %s" % (newlibname,))
+                    # XXX TODO : replace the nonsense above with
+                    # ext_to_copy = ['lib', 'pdb']
+                    ext_to_copy = ['pdb',]
+                    for ext in ext_to_copy:
+                        name = soname.new(ext=ext)
+                        newname = newexename.new(basename=soname.basename)
+                        shutil.copyfile(str(name), str(newname.new(ext=ext)))
+                        self.log.info("copied: %s" % (newname,))
             self.c_entryp = newexename
         self.log.info('usession directory: %s' % (udir,))
         self.log.info("created: %s" % (self.c_entryp,))
diff --git a/rpython/translator/platform/windows.py b/rpython/translator/platform/windows.py
--- a/rpython/translator/platform/windows.py
+++ b/rpython/translator/platform/windows.py
@@ -410,7 +410,7 @@
                    'int main(int argc, char* argv[]) '
                    '{ return $(PYPY_MAIN_FUNCTION)(argc, argv); } > $@')
             m.rule('$(DEFAULT_TARGET)', ['$(TARGET)', 'main.obj'],
-                   ['$(CC_LINK) /nologo main.obj $(SHARED_IMPORT_LIB) /out:$@ /MANIFEST /MANIFESTFILE:$*.manifest',
+                   ['$(CC_LINK) /nologo /debug main.obj $(SHARED_IMPORT_LIB) /out:$@ /MANIFEST /MANIFESTFILE:$*.manifest',
                     'mt.exe -nologo -manifest $*.manifest -outputresource:$@;1',
                     ])
             m.rule('debugmode_$(DEFAULT_TARGET)', ['debugmode_$(TARGET)', 'main.obj'],
diff --git a/rpython/translator/test/test_driver.py b/rpython/translator/test/test_driver.py
--- a/rpython/translator/test/test_driver.py
+++ b/rpython/translator/test/test_driver.py
@@ -55,12 +55,15 @@
     src_name = udir.join('src/dydy2.exe')
     dll_name = udir.join('src/pypy.dll')
     lib_name = udir.join('src/pypy.lib')
+    pdb_name = udir.join('src/pypy.pdb')
     src_name.ensure()
     src_name.write('exe')
     dll_name.ensure()
     dll_name.write('dll')
     lib_name.ensure()
     lib_name.write('lib')
+    pdb_name.ensure()
+    pdb_name.write('pdb')
     dst_name.ensure()
 
     class CBuilder(object):
@@ -75,6 +78,8 @@
     assert dst_name.new(ext='lib').read() == 'lib'
 
 def test_shutil_copy():
+    if os.name == 'nt':
+        py.test.skip('Windows cannot copy or rename to an in-use file')
     a = udir.join('file_a')
     b = udir.join('file_a')
     a.write('hello')


More information about the pypy-commit mailing list