[pypy-svn] r60496 - in pypy/branch/oo-jit/pypy/jit/tl: . test
antocuni at codespeak.net
antocuni at codespeak.net
Sun Dec 14 14:11:14 CET 2008
Author: antocuni
Date: Sun Dec 14 14:11:12 2008
New Revision: 60496
Modified:
pypy/branch/oo-jit/pypy/jit/tl/test/test_tlc.py
pypy/branch/oo-jit/pypy/jit/tl/tlc.py
Log:
don't crash if we don't return anything from a function/method
Modified: pypy/branch/oo-jit/pypy/jit/tl/test/test_tlc.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/tl/test/test_tlc.py (original)
+++ pypy/branch/oo-jit/pypy/jit/tl/test/test_tlc.py Sun Dec 14 14:11:12 2008
@@ -243,3 +243,16 @@
""", pool)
res = interp_eval(bytecode, 0, nil, pool)
assert res.int_o() == 42
+
+ def test_call_without_return_value(self):
+ from pypy.jit.tl.tlc import interp_eval, nil
+ pool = ConstantPool()
+ bytecode = compile("""
+ CALL foo
+ PUSH 42
+ RETURN
+ foo:
+ RETURN
+ """, pool)
+ res = interp_eval(bytecode, 0, nil, pool)
+ assert res.int_o() == 42
Modified: pypy/branch/oo-jit/pypy/jit/tl/tlc.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/tl/tlc.py (original)
+++ pypy/branch/oo-jit/pypy/jit/tl/tlc.py Sun Dec 14 14:11:12 2008
@@ -395,10 +395,14 @@
elif opcode == RETURN:
if framestack.isempty():
break
- res = stack.pop()
+ if stack:
+ res = stack.pop()
+ else:
+ res = None
pc2, args, stack = framestack.pop()
pc = hint(pc2, promote=True)
- stack.append(res)
+ if res:
+ stack.append(res)
elif opcode == PUSHARG:
stack.append(args[0])
More information about the Pypy-commit
mailing list