diff options
| author | Serhiy Storchaka <storchaka@gmail.com> | 2018-03-11 08:32:47 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-03-11 08:32:47 +0200 |
| commit | 26c9f565d016db21257a60d29ab2c99383dd5ac7 (patch) | |
| tree | faaef311a9bfff6549d59eb6149d562c22eab01c /Lib/test | |
| parent | 51302a5fcc557e6afc0bf1e3b371f5f37c76dc77 (diff) | |
| download | cpython-git-26c9f565d016db21257a60d29ab2c99383dd5ac7.tar.gz | |
bpo-33026: Fix jumping out of "with" block by setting f_lineno. (#6026)
Diffstat (limited to 'Lib/test')
| -rw-r--r-- | Lib/test/test_sys_settrace.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py index 7df10cb5c1..72cce33392 100644 --- a/Lib/test/test_sys_settrace.py +++ b/Lib/test/test_sys_settrace.py @@ -827,6 +827,34 @@ class JumpTestCase(unittest.TestCase): with tracecontext(output, 4): output.append(5) + @jump_test(4, 5, [1, 3, 5, 6]) + def test_jump_out_of_with_block_within_for_block(output): + output.append(1) + for i in [1]: + with tracecontext(output, 3): + output.append(4) + output.append(5) + output.append(6) + + @jump_test(4, 5, [1, 2, 3, 5, -2, 6]) + def test_jump_out_of_with_block_within_with_block(output): + output.append(1) + with tracecontext(output, 2): + with tracecontext(output, 3): + output.append(4) + output.append(5) + output.append(6) + + @jump_test(5, 6, [2, 4, 6, 7]) + def test_jump_out_of_with_block_within_finally_block(output): + try: + output.append(2) + finally: + with tracecontext(output, 4): + output.append(5) + output.append(6) + output.append(7) + @jump_test(8, 11, [1, 3, 5, 11, 12]) def test_jump_out_of_complex_nested_blocks(output): output.append(1) |
