diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2022-07-22 16:28:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-22 16:28:03 -0700 |
commit | e4d3a96a113070fde433834a6c9fb79ebeebad4a (patch) | |
tree | 6033a5169cbf594c2d9c6b42c6d3d5b96ebba3c1 /Lib/test/test_sys_settrace.py | |
parent | 900bfc53cb133e8bc2b122362ec04256f623d5b0 (diff) | |
download | cpython-e4d3a96a113070fde433834a6c9fb79ebeebad4a.tar.gz cpython-e4d3a96a113070fde433834a6c9fb79ebeebad4a.zip |
GH-94438: Handle extended arguments and conditional pops in mark_stacks (GH-95110)
Diffstat (limited to 'Lib/test/test_sys_settrace.py')
-rw-r--r-- | Lib/test/test_sys_settrace.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py index 8d0c3171441..9f1aa81dbcd 100644 --- a/Lib/test/test_sys_settrace.py +++ b/Lib/test/test_sys_settrace.py @@ -2685,6 +2685,42 @@ output.append(4) ) output.append(15) + @jump_test(2, 3, [1, 3]) + def test_jump_extended_args_unpack_ex_simple(output): + output.append(1) + _, *_, _ = output.append(2) or "Spam" + output.append(3) + + @jump_test(3, 4, [1, 4, 4, 5]) + def test_jump_extended_args_unpack_ex_tricky(output): + output.append(1) + ( + _, *_, _ + ) = output.append(4) or "Spam" + output.append(5) + + def test_jump_extended_args_for_iter(self): + # In addition to failing when extended arg handling is broken, this can + # also hang for a *very* long time: + source = [ + "def f(output):", + " output.append(1)", + " for _ in spam:", + *(f" output.append({i})" for i in range(3, 100_000)), + f" output.append(100_000)", + ] + namespace = {} + exec("\n".join(source), namespace) + f = namespace["f"] + self.run_test(f, 2, 100_000, [1, 100_000]) + + @jump_test(2, 3, [1, 3]) + def test_jump_or_pop(output): + output.append(1) + _ = output.append(2) and "Spam" + output.append(3) + + class TestExtendedArgs(unittest.TestCase): def setUp(self): |