Author: Armin Rigo <[email protected]>
Branch:
Changeset: r76759:d77902fffe58
Date: 2015-04-09 14:45 +0200
http://bitbucket.org/pypy/pypy/changeset/d77902fffe58/
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
@@ -565,10 +565,10 @@
ops.INPLACE_OR: -1,
ops.INPLACE_XOR: -1,
- ops.SLICE+0: 1,
- ops.SLICE+1: 0,
- ops.SLICE+2: 0,
- ops.SLICE+3: -1,
+ ops.SLICE+0: 0,
+ ops.SLICE+1: -1,
+ ops.SLICE+2: -1,
+ ops.SLICE+3: -2,
ops.STORE_SLICE+0: -2,
ops.STORE_SLICE+1: -3,
ops.STORE_SLICE+2: -3,
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
@@ -802,6 +802,16 @@
code = compile_with_astcompiler(source, 'exec', self.space)
assert code.co_stacksize == 4
+ def test_stackeffect_bug5(self):
+ source = """if 1:
+ a[:]; a[:]; a[:]; a[:]; a[:]; a[:]
+ a[1:]; a[1:]; a[1:]; a[1:]; a[1:]; a[1:]
+ a[:2]; a[:2]; a[:2]; a[:2]; a[:2]; a[:2]
+ a[1:2]; a[1:2]; a[1:2]; a[1:2]; a[1:2]; a[1:2]
+ """
+ code = compile_with_astcompiler(source, 'exec', self.space)
+ assert code.co_stacksize == 3
+
def test_lambda(self):
yield self.st, "y = lambda x: x", "y(4)", 4
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit