[pypy-commit] pypy default: merge heads

arigo noreply at buildbot.pypy.org
Wed Mar 4 02:03:13 CET 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r76236:167ad5df04a2
Date: 2015-03-04 02:03 +0100
http://bitbucket.org/pypy/pypy/changeset/167ad5df04a2/

Log:	merge heads

diff --git a/rpython/flowspace/test/test_objspace.py b/rpython/flowspace/test/test_objspace.py
--- a/rpython/flowspace/test/test_objspace.py
+++ b/rpython/flowspace/test/test_objspace.py
@@ -204,6 +204,22 @@
     def test_break_continue(self):
         x = self.codetest(self.break_continue)
 
+    def test_break_from_handler(self):
+        def f(x):
+            while True:
+                try:
+                    x()
+                except TypeError:
+                    if x:
+                        raise
+                    break
+        assert f(0) is None
+        graph = self.codetest(f)
+        simplify_graph(graph)
+        entrymap = mkentrymap(graph)
+        links = entrymap[graph.returnblock]
+        assert len(links) == 1
+
     #__________________________________________________________
     def unpack_tuple(lst):
         a, b, c = lst
@@ -245,6 +261,19 @@
     def test_finallys(self):
         x = self.codetest(self.finallys)
 
+    def test_branching_in_finally(self):
+        def f(x, y):
+            try:
+                return x
+            finally:
+                if x:
+                    x = 0
+                if y > 0:
+                    y -= 1
+                return y
+        self.codetest(f)
+
+
     #__________________________________________________________
     def const_pow():
         return 2 ** 5
@@ -942,6 +971,22 @@
             'simple_call': 4, # __enter__, g and 2 possible calls to __exit__
             }
 
+    def test_return_in_with(self):
+        def f(x):
+            with x:
+                return 1
+        graph = self.codetest(f)
+        simplify_graph(graph)
+        assert self.all_operations(graph) == {'getattr': 2, 'simple_call': 2}
+
+    def test_break_in_with(self):
+        def f(n, x):
+            for i in range(n):
+                with x:
+                    break
+            return 1
+        self.codetest(f)
+
     def monkey_patch_code(self, code, stacksize, flags, codestring, names, varnames):
         c = code
         return types.CodeType(c.co_argcount, c.co_nlocals, stacksize, flags,


More information about the pypy-commit mailing list