[pypy-svn] r31952 - pypy/dist/pypy/tool

arigo at codespeak.net arigo at codespeak.net
Sat Sep 2 18:37:04 CEST 2006


Author: arigo
Date: Sat Sep  2 18:37:02 2006
New Revision: 31952

Modified:
   pypy/dist/pypy/tool/error.py
Log:
(pedronis, arigo)

Tentative: a format for annotation error with an order and an amount of
blank lines that seems to help.  Very subjective, of course.



Modified: pypy/dist/pypy/tool/error.py
==============================================================================
--- pypy/dist/pypy/tool/error.py	(original)
+++ pypy/dist/pypy/tool/error.py	Sat Sep  2 18:37:02 2006
@@ -50,12 +50,15 @@
                 else:
                     linerange = (operline, operline)
                     here = None
-        lines = ["Happened at file %s line %d" % (graph.filename, here or linerange[0])]
+        lines = ["Happened at file %s line %d" % (graph.filename, here or linerange[0]), ""]
         for n in range(max(0, linerange[0]-show_lines_of_code), \
             min(linerange[1]+1+show_lines_of_code, len(graph_lines)+graph.startline)):
-            lines.append(graph_lines[n-graph.startline])
             if n == here:
-                lines.append('^ HERE')
+                prefix = '==> '
+            else:
+                prefix = '    '
+            lines.append(prefix + graph_lines[n-graph.startline])
+        lines.append("")
         return lines
 
 class FlowingError(Exception):
@@ -65,7 +68,7 @@
     pass
 
 def gather_error(annotator, block, graph):
-    msg = []
+    msg = [""]
     msg.append('-+' * 30)
     from pypy.annotation import model
     if model.DEBUG:
@@ -73,6 +76,11 @@
         _, _, operindex = annotator.why_not_annotated[block][1].break_at
         oper = block.operations[operindex]
         msg.append(" " + str(oper))
+    else:
+        msg.append("Blocked block")
+        operindex = None
+    msg += source_lines(graph, block, operindex, long=True)
+    if model.DEBUG:
         if SHOW_ANNOTATIONS:
             msg.append("Known variable annotations:")
             for arg in oper.args + [oper.result]:
@@ -81,20 +89,15 @@
                         msg.append(" " + str(arg) + " = " + str(annotator.binding(arg)))
                     except KeyError:
                         pass
-            msg.append("")
         if SHOW_TRACEBACK:
             msg.extend(traceback.format_exception(*annotator.why_not_annotated[block]))
-    else:
-        msg.append("Blocked block")
-        operindex = None
-    msg += source_lines(graph, block, operindex, long=True)
     return "\n".join(msg)
 
 def format_blocked_annotation_error(annotator, blocked_blocks, graph):
-    text = ""
+    text = []
     for block in blocked_blocks:
-        text += gather_error(annotator, block, graph)
-    return text
+        text.append(gather_error(annotator, block, graph))
+    return '\n'.join(text)
     
 def format_someobject_error(annotator, position_key, what, s_value, called_from_graph):
     #block = getattr(annotator, 'flowin_block', None) or block



More information about the Pypy-commit mailing list