[pypy-commit] pypy translation-cleanup: Move FlowingError handling from FlowObjSpace to FSFrame
rlamy
noreply at buildbot.pypy.org
Thu Sep 20 19:39:20 CEST 2012
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: translation-cleanup
Changeset: r57434:2010f1ab50a8
Date: 2012-09-19 02:54 +0100
http://bitbucket.org/pypy/pypy/changeset/2010f1ab50a8/
Log: Move FlowingError handling from FlowObjSpace to FSFrame
+ rationalise some imports
diff --git a/pypy/objspace/flow/flowcontext.py b/pypy/objspace/flow/flowcontext.py
--- a/pypy/objspace/flow/flowcontext.py
+++ b/pypy/objspace/flow/flowcontext.py
@@ -1,6 +1,6 @@
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
@@ -421,6 +421,14 @@
assert w_result is not None
link = Link([w_result], self.graph.returnblock)
self.recorder.crnt_block.closeblock(link)
+
+ 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):
diff --git a/pypy/objspace/flow/objspace.py b/pypy/objspace/flow/objspace.py
--- a/pypy/objspace/flow/objspace.py
+++ b/pypy/objspace/flow/objspace.py
@@ -3,13 +3,12 @@
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
@@ -191,7 +190,7 @@
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" %
check_class.__name__)
if not isinstance(check_class, tuple):
# the simple case
@@ -222,17 +221,7 @@
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
fixeggblocks(graph)
checkgraph(graph)
diff --git a/pypy/objspace/flow/test/test_objspace.py b/pypy/objspace/flow/test/test_objspace.py
--- a/pypy/objspace/flow/test/test_objspace.py
+++ b/pypy/objspace/flow/test/test_objspace.py
@@ -5,8 +5,8 @@
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
@@ -857,7 +857,7 @@
c.co_lnotab)
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]
@@ -865,7 +865,7 @@
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)
@@ -985,14 +985,14 @@
f()
except NotImplementedError:
pass
- py.test.raises(error.FlowingError, "self.codetest(f)")
+ py.test.raises(FlowingError, "self.codetest(f)")
#
def f():
try:
f()
except AssertionError:
pass
- py.test.raises(error.FlowingError, "self.codetest(f)")
+ py.test.raises(FlowingError, "self.codetest(f)")
def test_locals_dict(self):
def f():
More information about the pypy-commit
mailing list