[pypy-commit] pypy default: merged upstream.

alex_gaynor noreply at buildbot.pypy.org
Sat Sep 24 19:18:11 CEST 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r47579:ecc4e349999f
Date: 2011-09-24 13:17 -0400
http://bitbucket.org/pypy/pypy/changeset/ecc4e349999f/

Log:	merged upstream.

diff --git a/pypy/rpython/module/ll_os_stat.py b/pypy/rpython/module/ll_os_stat.py
--- a/pypy/rpython/module/ll_os_stat.py
+++ b/pypy/rpython/module/ll_os_stat.py
@@ -173,7 +173,8 @@
         _compilation_info_ = compilation_info
         STAT_STRUCT = platform.Struct('struct %s' % _name_struct_stat, LL_STAT_FIELDS)
     try:
-        config = platform.configure(CConfig)
+        config = platform.configure(CConfig, ignore_errors=
+                                    try_to_add is not None)
     except platform.CompilationError:
         if try_to_add:
             return    # failed to add this field, give up
diff --git a/pypy/rpython/tool/rffi_platform.py b/pypy/rpython/tool/rffi_platform.py
--- a/pypy/rpython/tool/rffi_platform.py
+++ b/pypy/rpython/tool/rffi_platform.py
@@ -171,7 +171,7 @@
         eci = self.config._compilation_info_
         try_compile_cache([self.path], eci)
 
-def configure(CConfig):
+def configure(CConfig, ignore_errors=False):
     """Examine the local system by running the C compiler.
     The CConfig class contains CConfigEntry attribues that describe
     what should be inspected; configure() returns a dict mapping
@@ -199,7 +199,8 @@
         writer.close()
 
         eci = CConfig._compilation_info_
-        infolist = list(run_example_code(writer.path, eci))
+        infolist = list(run_example_code(writer.path, eci,
+                                         ignore_errors=ignore_errors))
         assert len(infolist) == len(entries)
 
         resultinfo = {}
@@ -680,10 +681,10 @@
 }
 """
 
-def run_example_code(filepath, eci):
+def run_example_code(filepath, eci, ignore_errors=False):
     eci = eci.convert_sources_to_files(being_main=True)
     files = [filepath]
-    output = build_executable_cache(files, eci)
+    output = build_executable_cache(files, eci, ignore_errors=ignore_errors)
     section = None
     for line in output.splitlines():
         line = line.strip()
diff --git a/pypy/tool/gcc_cache.py b/pypy/tool/gcc_cache.py
--- a/pypy/tool/gcc_cache.py
+++ b/pypy/tool/gcc_cache.py
@@ -16,7 +16,7 @@
     hash = md5(key).hexdigest()
     return cache_dir.join(hash)
 
-def build_executable_cache(c_files, eci):
+def build_executable_cache(c_files, eci, ignore_errors=False):
     "Builds and run a program; caches the result"
     # Import 'platform' every time, the compiler may have been changed
     from pypy.translator.platform import platform
@@ -24,7 +24,18 @@
     try:
         return path.read()
     except py.error.Error:
-        result = platform.execute(platform.compile(c_files, eci))
+        _previous = platform.log_errors
+        try:
+            if ignore_errors:
+                platform.log_errors = False
+            result = platform.execute(platform.compile(c_files, eci))
+        finally:
+            if ignore_errors:
+                del platform.log_errors
+            # ^^^remove from the instance --- needed so that it can
+            # compare equal to another instance without it
+            if platform.log_errors != _previous:
+                platform.log_errors = _previous
         path.write(result.out)
         return result.out
 
diff --git a/pypy/tool/test/test_gcc_cache.py b/pypy/tool/test/test_gcc_cache.py
--- a/pypy/tool/test/test_gcc_cache.py
+++ b/pypy/tool/test/test_gcc_cache.py
@@ -77,3 +77,17 @@
     finally:
         sys.stderr = oldstderr
     assert 'ERROR' not in capture.getvalue().upper()
+
+def test_execute_code_ignore_errors():
+    f = localudir.join('z.c')
+    f.write("""this file is not valid C code\n""")
+    eci = ExternalCompilationInfo()
+    oldstderr = sys.stderr
+    try:
+        sys.stderr = capture = cStringIO.StringIO()
+        py.test.raises(CompilationError, build_executable_cache,
+                       [f], eci, True)
+    finally:
+        sys.stderr = oldstderr
+    assert 'ERROR' not in capture.getvalue().upper()
+    


More information about the pypy-commit mailing list