Ronan Lamy  committed 2010f1a

Move FlowingError handling from FlowObjSpace to FSFrame

+ rationalise some imports

  • Participants
  • Parent commits 29ddce6
  • Branches translation-cleanup

Comments (0)

Files changed (3)

File pypy/objspace/flow/

 import collections
 import sys
-from pypy.tool.error import FlowingError
+from pypy.tool.error import FlowingError, format_global_error
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.pytraceback import PyTraceback
 from pypy.interpreter import pyframe
                 assert w_result is not None
                 link = Link([w_result], self.graph.returnblock)
+            except FlowingError, a:
+                # attach additional source info to AnnotatorError
+                _, _, tb = sys.exc_info()
+                formatted = format_global_error(self.graph, self.last_instr,
+                                                    str(a))
+                e = FlowingError(formatted)
+                raise FlowingError, e, tb
         del self.recorder
     def mergeblock(self, currentblock, currentstate):

File pypy/objspace/flow/

 import sys
 import operator
 import types
-from pypy.tool import error
 from pypy.interpreter.baseobjspace import ObjSpace, Wrappable
 from pypy.interpreter import pyframe, argument
 from pypy.objspace.flow.model import *
 from pypy.objspace.flow import operation
 from pypy.objspace.flow.flowcontext import (FlowSpaceFrame, fixeggblocks,
-    OperationThatShouldNotBePropagatedError, FSException)
+    OperationThatShouldNotBePropagatedError, FSException, FlowingError)
 from pypy.objspace.flow.specialcase import SPECIAL_CASES
 from pypy.rlib.unroll import unrolling_iterable, _unroller
 from pypy.rlib import rstackovf, rarithmetic
         except UnwrapException:
             raise Exception, "non-constant except guard"
         if check_class in (NotImplementedError, AssertionError):
-            raise error.FlowingError("Catching %s is not valid in RPython" %
+            raise FlowingError("Catching %s is not valid in RPython" %
         if not isinstance(check_class, tuple):
             # the simple case
         if func.func_doc and func.func_doc.lstrip().startswith('NOT_RPYTHON'):
             raise Exception, "%r is tagged as NOT_RPYTHON" % (func,)
         frame = self.frame = FlowSpaceFrame(self, func, constargs)
-        try:
-            frame.build_flow()
-        except error.FlowingError, a:
-            # attach additional source info to AnnotatorError
-            _, _, tb = sys.exc_info()
-            formated = error.format_global_error(frame.graph, self.frame.last_instr,
-                                                 str(a))
-            e = error.FlowingError(formated)
-            raise error.FlowingError, e, tb
+        frame.build_flow()
         graph = frame.graph

File pypy/objspace/flow/test/

 from pypy.objspace.flow.model import mkentrymap, c_last_exception
 from pypy.interpreter.argument import Arguments
 from pypy.translator.simplify import simplify_graph
-from pypy.objspace.flow.objspace import FlowObjSpace, error
-from pypy.objspace.flow import objspace, flowcontext
+from pypy.objspace.flow.objspace import FlowObjSpace
+from pypy.objspace.flow.flowcontext import FlowingError, FlowSpaceFrame
 from pypy import conftest
 from pypy.tool.stdlib_opcode import bytecode_spec
 from pypy.interpreter.pyframe import PyFrame
     def patch_opcodes(self, *opcodes):
-        flow_meth_names = flowcontext.FlowSpaceFrame.opcode_method_names
+        flow_meth_names = FlowSpaceFrame.opcode_method_names
         pyframe_meth_names = PyFrame.opcode_method_names
         for name in opcodes:
             num = bytecode_spec.opmap[name]
             flow_meth_names[num] = pyframe_meth_names[num]
     def unpatch_opcodes(self, *opcodes):
-        flow_meth_names = flowcontext.FlowSpaceFrame.opcode_method_names
+        flow_meth_names = FlowSpaceFrame.opcode_method_names
         for name in opcodes:
             num = bytecode_spec.opmap[name]
             flow_meth_names[num] = getattr(self, 'old_' + name)
             except NotImplementedError:
-        py.test.raises(error.FlowingError, "self.codetest(f)")
+        py.test.raises(FlowingError, "self.codetest(f)")
         def f():
             except AssertionError:
-        py.test.raises(error.FlowingError, "self.codetest(f)")
+        py.test.raises(FlowingError, "self.codetest(f)")
     def test_locals_dict(self):
         def f():