Author: Ronan Lamy <[email protected]>
Branch: translation-cleanup
Changeset: r57435:fa5795313192
Date: 2012-09-19 05:48 +0100
http://bitbucket.org/pypy/pypy/changeset/fa5795313192/

Log:    Use FlowingError only in the flow space

diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -22,8 +22,7 @@
 
     def __init__(self, w_type, w_value, tb=None):
         if not we_are_translated() and w_type is None:
-            from pypy.tool.error import FlowingError
-            raise FlowingError(w_value)
+            raise ValueError
         self.setup(w_type)
         self._w_value = w_value
         self._application_traceback = tb
@@ -328,8 +327,7 @@
                 for i, attr in entries:
                     setattr(self, attr, args[i])
                 if not we_are_translated() and w_type is None:
-                    from pypy.tool.error import FlowingError
-                    raise FlowingError(self._compute_value())
+                    raise ValueError
             def _compute_value(self):
                 lst = [None] * (len(formats) + len(formats) + 1)
                 for i, attr in entries:
@@ -393,7 +391,7 @@
         return OperationError(exc, w_error)
 
 def wrap_oserror2(space, e, w_filename=None, exception_name='w_OSError',
-                  w_exception_class=None): 
+                  w_exception_class=None):
     assert isinstance(e, OSError)
 
     if _WINDOWS and isinstance(e, WindowsError):
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, format_global_error
+from pypy.tool.error import format_global_error
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.pytraceback import PyTraceback
 from pypy.interpreter import pyframe
@@ -15,6 +15,9 @@
         recursively_flatten)
 from pypy.objspace.flow.bytecode import HostCode
 
+class FlowingError(Exception):
+    pass
+
 class StopFlowing(Exception):
     pass
 
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
@@ -1004,6 +1004,19 @@
         assert graph.startblock.exits[0].target == graph.returnblock
 
 
+    def test_global_variable(self):
+        def global_var_missing():
+            return a
+
+        with py.test.raises(FlowingError) as rex:
+            self.codetest(global_var_missing)
+        assert str(rex.exconly()).find("global variable 'a' undeclared")
+
+    def test_eval(self):
+        exec("def f(): return a")
+        with py.test.raises(FlowingError):
+            self.codetest(f)
+
 DATA = {'x': 5,
         'y': 6}
 
diff --git a/pypy/tool/error.py b/pypy/tool/error.py
--- a/pypy/tool/error.py
+++ b/pypy/tool/error.py
@@ -65,9 +65,6 @@
     lines = source_lines1(graph, *args, **kwds)
     return ['In %r:' % (graph,)] + lines
 
-class FlowingError(Exception):
-    pass
-
 class AnnotatorError(Exception):
     pass
 
diff --git a/pypy/tool/test/test_error.py b/pypy/tool/test/test_error.py
--- a/pypy/tool/test/test_error.py
+++ b/pypy/tool/test/test_error.py
@@ -3,7 +3,7 @@
 """
 
 from pypy.translator.translator import TranslationContext
-from pypy.tool.error import FlowingError, AnnotatorError, NoSuchAttrError
+from pypy.tool.error import AnnotatorError, NoSuchAttrError
 from pypy.annotation.policy import BasicAnnotatorPolicy
 
 import py
@@ -15,20 +15,13 @@
     t = TranslationContext()
     t.buildannotator(policy=Policy()).build_types(function, annotation)
 
-def test_global_variable():
-    def global_var_missing():
-        return a
-    
-    rex = py.test.raises(FlowingError, compile_function, global_var_missing)
-    assert str(rex.exconly()).find("global variable 'a' undeclared")
-
 class AAA(object):
     pass
 
 def test_blocked_inference1():
     def blocked_inference():
         return AAA().m()
-    
+
     py.test.raises(AnnotatorError, compile_function, blocked_inference)
 
 def test_blocked_inference2():
@@ -36,7 +29,7 @@
         a = AAA()
         b = a.x
         return b
-    
+
     py.test.raises(AnnotatorError, compile_function, blocked_inference)
 
 def test_someobject():
@@ -59,14 +52,9 @@
 
     py.test.raises(AnnotatorError, compile_function, someobject_deg, [int])
 
-def test_eval():
-    exec("def f(): return a")
-    
-    py.test.raises(FlowingError, compile_function, f)
-
 def test_eval_someobject():
     exec("def f(n):\n if n == 2:\n  return 'a'\n else:\n  return 3")
-    
+
     py.test.raises(AnnotatorError, compile_function, f, [int])
 
 def test_someobject_from_call():
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to