[pypy-commit] pypy default: Test and fix
arigo
noreply at buildbot.pypy.org
Thu Apr 9 14:39:08 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r76758:72049e6e23d8
Date: 2015-04-09 14:37 +0200
http://bitbucket.org/pypy/pypy/changeset/72049e6e23d8/
Log: Test and fix
diff --git a/pypy/interpreter/astcompiler/assemble.py b/pypy/interpreter/astcompiler/assemble.py
--- a/pypy/interpreter/astcompiler/assemble.py
+++ b/pypy/interpreter/astcompiler/assemble.py
@@ -406,7 +406,9 @@
elif (jump_op == ops.SETUP_FINALLY or
jump_op == ops.SETUP_EXCEPT or
jump_op == ops.SETUP_WITH):
- target_depth += 3
+ if jump_op == ops.SETUP_WITH:
+ target_depth -= 1 # ignore the w_result just pushed
+ target_depth += 3 # add [exc_type, exc, unroller]
if target_depth > self._max_depth:
self._max_depth = target_depth
elif (jump_op == ops.JUMP_IF_TRUE_OR_POP or
diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py b/pypy/interpreter/astcompiler/test/test_compiler.py
--- a/pypy/interpreter/astcompiler/test/test_compiler.py
+++ b/pypy/interpreter/astcompiler/test/test_compiler.py
@@ -790,6 +790,18 @@
code = compile_with_astcompiler(source, 'exec', self.space)
assert code.co_stacksize == 3
+ def test_stackeffect_bug4(self):
+ source = """if 1:
+ with a: pass
+ with a: pass
+ with a: pass
+ with a: pass
+ with a: pass
+ with a: pass
+ """
+ code = compile_with_astcompiler(source, 'exec', self.space)
+ assert code.co_stacksize == 4
+
def test_lambda(self):
yield self.st, "y = lambda x: x", "y(4)", 4
More information about the pypy-commit
mailing list