mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-40228: More robust frame.setlineno. (GH-19437)
More robust frame.setlineno. Makes no assumptions about source->bytecode translation.
This commit is contained in:
parent
ec9bea4a37
commit
57697245e1
3 changed files with 278 additions and 339 deletions
|
@ -948,8 +948,8 @@ class JumpTestCase(unittest.TestCase):
|
|||
output.append(11)
|
||||
output.append(12)
|
||||
|
||||
@jump_test(5, 11, [2, 4, 12])
|
||||
def test_jump_over_return_try_finally_in_finally_block(output):
|
||||
@jump_test(5, 11, [2, 4], (ValueError, 'unreachable'))
|
||||
def test_no_jump_over_return_try_finally_in_finally_block(output):
|
||||
try:
|
||||
output.append(2)
|
||||
finally:
|
||||
|
@ -963,8 +963,8 @@ class JumpTestCase(unittest.TestCase):
|
|||
pass
|
||||
output.append(12)
|
||||
|
||||
@jump_test(3, 4, [1, 4])
|
||||
def test_jump_infinite_while_loop(output):
|
||||
@jump_test(3, 4, [1], (ValueError, 'unreachable'))
|
||||
def test_no_jump_infinite_while_loop(output):
|
||||
output.append(1)
|
||||
while True:
|
||||
output.append(3)
|
||||
|
@ -1357,16 +1357,16 @@ class JumpTestCase(unittest.TestCase):
|
|||
output.append(7)
|
||||
output.append(8)
|
||||
|
||||
@jump_test(1, 5, [], (ValueError, "into a 'finally'"))
|
||||
def test_no_jump_into_finally_block(output):
|
||||
@jump_test(1, 5, [5])
|
||||
def test_jump_into_finally_block(output):
|
||||
output.append(1)
|
||||
try:
|
||||
output.append(3)
|
||||
finally:
|
||||
output.append(5)
|
||||
|
||||
@jump_test(3, 6, [2, 5, 6], (ValueError, "into a 'finally'"))
|
||||
def test_no_jump_into_finally_block_from_try_block(output):
|
||||
@jump_test(3, 6, [2, 6, 7])
|
||||
def test_jump_into_finally_block_from_try_block(output):
|
||||
try:
|
||||
output.append(2)
|
||||
output.append(3)
|
||||
|
@ -1375,8 +1375,8 @@ class JumpTestCase(unittest.TestCase):
|
|||
output.append(6)
|
||||
output.append(7)
|
||||
|
||||
@jump_test(5, 1, [1, 3], (ValueError, "out of a 'finally'"))
|
||||
def test_no_jump_out_of_finally_block(output):
|
||||
@jump_test(5, 1, [1, 3, 1, 3, 5])
|
||||
def test_jump_out_of_finally_block(output):
|
||||
output.append(1)
|
||||
try:
|
||||
output.append(3)
|
||||
|
@ -1441,23 +1441,23 @@ class JumpTestCase(unittest.TestCase):
|
|||
output.append(6)
|
||||
output.append(7)
|
||||
|
||||
@jump_test(3, 5, [1, 2, -2], (ValueError, 'into'))
|
||||
def test_no_jump_between_with_blocks(output):
|
||||
@jump_test(3, 5, [1, 2, 5, -2])
|
||||
def test_jump_between_with_blocks(output):
|
||||
output.append(1)
|
||||
with tracecontext(output, 2):
|
||||
output.append(3)
|
||||
with tracecontext(output, 4):
|
||||
output.append(5)
|
||||
|
||||
@async_jump_test(3, 5, [1, 2, -2], (ValueError, 'into'))
|
||||
async def test_no_jump_between_async_with_blocks(output):
|
||||
@async_jump_test(3, 5, [1, 2, 5, -2])
|
||||
async def test_jump_between_async_with_blocks(output):
|
||||
output.append(1)
|
||||
async with asynctracecontext(output, 2):
|
||||
output.append(3)
|
||||
async with asynctracecontext(output, 4):
|
||||
output.append(5)
|
||||
|
||||
@jump_test(5, 7, [2, 4], (ValueError, 'finally'))
|
||||
@jump_test(5, 7, [2, 4], (ValueError, "unreachable"))
|
||||
def test_no_jump_over_return_out_of_finally_block(output):
|
||||
try:
|
||||
output.append(2)
|
||||
|
@ -1551,9 +1551,8 @@ output.append(4)
|
|||
output.append(1)
|
||||
1 / 0
|
||||
|
||||
@jump_test(3, 2, [2], event='return', error=(ValueError,
|
||||
"can't jump from a 'yield' statement"))
|
||||
def test_no_jump_from_yield(output):
|
||||
@jump_test(3, 2, [2, 5], event='return')
|
||||
def test_jump_from_yield(output):
|
||||
def gen():
|
||||
output.append(2)
|
||||
yield 3
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue