diff options
author | Mark Shannon <mark@hotpy.org> | 2021-01-04 18:06:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-04 18:06:55 (GMT) |
commit | 127dde591686816e379d1add015304e6b9fb6954 (patch) | |
tree | da5cd0463d04c3cb69c00e709b45144dd03621c0 /Lib | |
parent | de833b601319da15d90c8f3cd3c44d239d6d5924 (diff) | |
download | cpython-127dde591686816e379d1add015304e6b9fb6954.zip cpython-127dde591686816e379d1add015304e6b9fb6954.tar.gz cpython-127dde591686816e379d1add015304e6b9fb6954.tar.bz2 |
bpo-42810: Mark jumps at end of if and try statements as artificial. (GH-24091)
* Mark jumps at end of if and try statements as artificial.
* Update importlib
* Add comment explaining the purpose of ADDOP_JUMP_NOLINE.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_sys_settrace.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py index 50b5672..83b0392 100644 --- a/Lib/test/test_sys_settrace.py +++ b/Lib/test/test_sys_settrace.py @@ -874,6 +874,48 @@ class TraceTestCase(unittest.TestCase): (5, 'line'), (5, 'return')]) + def test_nested_ifs(self): + + def func(): + a = b = 1 + if a == 1: + if b == 1: + x = 4 + else: + y = 6 + else: + z = 8 + + self.run_and_compare(func, + [(0, 'call'), + (1, 'line'), + (2, 'line'), + (3, 'line'), + (4, 'line'), + (4, 'return')]) + + def test_nested_try_if(self): + + def func(): + x = "hello" + try: + 3/0 + except ZeroDivisionError: + if x == 'raise': + raise ValueError() # line 6 + f = 7 + + self.run_and_compare(func, + [(0, 'call'), + (1, 'line'), + (2, 'line'), + (3, 'line'), + (3, 'exception'), + (4, 'line'), + (5, 'line'), + (7, 'line'), + (7, 'return')]) + class SkipLineEventsTraceTestCase(TraceTestCase): """Repeat the trace tests, but with per-line events skipped""" |