[pypy-commit] creflect default: If the tool crashes, output a #error line in the interrupted output file

arigo noreply at buildbot.pypy.org
Thu Nov 27 17:12:03 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r96:6eec004b93e6
Date: 2014-11-27 17:12 +0100
http://bitbucket.org/cffi/creflect/changeset/6eec004b93e6/

Log:	If the tool crashes, output a #error line in the interrupted output
	file

diff --git a/creflect/driver.py b/creflect/driver.py
--- a/creflect/driver.py
+++ b/creflect/driver.py
@@ -22,6 +22,19 @@
 
 def copy_file_and_expand(inputf, outputf, export_func_name='_creflect_main',
                          include_text_outside_creflect=True):
+    try:
+        _copy_file_and_expand(inputf, outputf, export_func_name,
+                              include_text_outside_creflect)
+    except Exception, e:
+        errmsg = str(e)
+        if errmsg:
+            errmsg = ': ' + errmsg
+        errmsg = e.__class__.__name__ + errmsg
+        outputf.write('\n#error %r\n' % (errmsg,))
+        raise
+
+def _copy_file_and_expand(inputf, outputf, export_func_name,
+                         include_text_outside_creflect):
     lineno = 0
     blocks = []
     while True:


More information about the pypy-commit mailing list