Author: Carl Friedrich Bolz-Tereick <[email protected]>
Branch: py3.6-fix-set-lineno
Changeset: r97394:577840a9fd64
Date: 2019-09-07 11:14 +0200
http://bitbucket.org/pypy/pypy/changeset/577840a9fd64/
Log: branch to try to fix the bugs in setting line number of a frame
diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -6,24 +6,23 @@
from rpython.rlib.debug import make_sure_not_resized, check_nonneg
from rpython.rlib.debug import ll_assert_not_none
from rpython.rlib.jit import hint
-from rpython.rlib.objectmodel import instantiate, specialize, we_are_translated
+from rpython.rlib.objectmodel import instantiate, we_are_translated
from rpython.rlib.objectmodel import not_rpython
-from rpython.rlib.rarithmetic import intmask, r_uint
+from rpython.rlib.rarithmetic import r_uint
from rpython.tool.pairtype import extendabletype
from pypy.interpreter import pycode, pytraceback
from pypy.interpreter.argument import Arguments
from pypy.interpreter.astcompiler import consts
from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter.error import (
- OperationError, get_cleared_operation_error, oefmt)
+from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.executioncontext import ExecutionContext
from pypy.interpreter.nestedscope import Cell
from pypy.tool import stdlib_opcode
# Define some opcodes used
for op in '''DUP_TOP POP_TOP SETUP_LOOP SETUP_EXCEPT SETUP_FINALLY SETUP_WITH
-SETUP_ASYNC_WITH POP_BLOCK END_FINALLY'''.split():
+SETUP_ASYNC_WITH POP_BLOCK END_FINALLY RETURN_VALUE'''.split():
globals()[op] = stdlib_opcode.opmap[op]
class FrameDebugData(object):
@@ -684,6 +683,7 @@
raise oefmt(space.w_ValueError,
"can't jump to 'except' line as there's no exception")
+ import pdb; pdb.set_trace()
# Don't jump inside or out of an except or a finally block.
# Note that CPython doesn't check except blocks,
# but that results in crashes (tested on 3.5.2+).
@@ -705,6 +705,12 @@
setup_op = ord(code[blockstack.pop()])
if setup_op != SETUP_LOOP:
endblock.append(addr)
+ elif op == RETURN_VALUE:
+ if len(blockstack) != 0:
+ # jump to finally block
+ setup_op = ord(code[blockstack.pop()])
+ assert setup_op == SETUP_FINALLY
+ endblock.append(addr)
elif op == END_FINALLY:
if len(endblock) <= 1:
raise oefmt(space.w_SystemError,
diff --git a/pypy/interpreter/test/test_pyframe.py
b/pypy/interpreter/test/test_pyframe.py
--- a/pypy/interpreter/test/test_pyframe.py
+++ b/pypy/interpreter/test/test_pyframe.py
@@ -48,7 +48,13 @@
tracer = JumpTracer(func)
sys.settrace(tracer.trace)
output = []
- func(output)
+ if getattr(func, "error", None) is None:
+ func(output)
+ else:
+ try:
+ func(output)
+ except BaseException as e:
+ assert type(e) is func.error
sys.settrace(None)
assert func.output == output
@@ -77,6 +83,20 @@
jump_out_of_block_backwards.output = [1, 3, 5, 1, 3, 5, 6, 7]
run_test(jump_out_of_block_backwards)
+ def jump_in_nested_finally_2(output):
+ try:
+ output.append(2)
+ 1/0
+ return
+ finally:
+ output.append(6)
+ output.append(7)
+ output.append(8)
+ jump_in_nested_finally_2.jump = (6, 7)
+ jump_in_nested_finally_2.output = [2, 7]
+ jump_in_nested_finally_2.error = ZeroDivisionError
+ run_test(jump_in_nested_finally_2)
+
def test_f_back_hidden(self):
if not hasattr(self, 'call_further'):
skip("not for runappdirect testing")
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit