summaryrefslogtreecommitdiff
path: root/Lib/test/test_sys_settrace.py
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2021-01-13 12:05:43 +0000
committerGitHub <noreply@github.com>2021-01-13 12:05:43 +0000
commit3bd6035b6baf1a7d51b7cc2c6bb2c81886236b67 (patch)
tree22746e3a5738e389725765ade3167911eba51b9a /Lib/test/test_sys_settrace.py
parent2396614b8958ad202378fd71a598eb4106ac5896 (diff)
downloadcpython-git-3bd6035b6baf1a7d51b7cc2c6bb2c81886236b67.tar.gz
bpo-42908: Mark cleanup code at end of try-except and with artificial (#24202)
* Mark bytecodes at end of try-except as artificial. * Make sure that the CFG is consistent throughout optimiization. * Extend line-number propagation logic so that implicit returns after 'try-except' or 'with' have the correct line numbers. * Update importlib
Diffstat (limited to 'Lib/test/test_sys_settrace.py')
-rw-r--r--Lib/test/test_sys_settrace.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py
index 83b03925c3..4298986250 100644
--- a/Lib/test/test_sys_settrace.py
+++ b/Lib/test/test_sys_settrace.py
@@ -916,6 +916,46 @@ class TraceTestCase(unittest.TestCase):
(7, 'line'),
(7, 'return')])
+ def test_if_false_in_with(self):
+
+ class C:
+ def __enter__(self):
+ return self
+ def __exit__(*args):
+ pass
+
+ def func():
+ with C():
+ if False:
+ pass
+
+ self.run_and_compare(func,
+ [(0, 'call'),
+ (1, 'line'),
+ (-5, 'call'),
+ (-4, 'line'),
+ (-4, 'return'),
+ (2, 'line'),
+ (-3, 'call'),
+ (-2, 'line'),
+ (-2, 'return'),
+ (2, 'return')])
+
+ def test_if_false_in_try_except(self):
+
+ def func():
+ try:
+ if False:
+ pass
+ except Exception:
+ X
+
+ self.run_and_compare(func,
+ [(0, 'call'),
+ (1, 'line'),
+ (2, 'line'),
+ (2, 'return')])
+
class SkipLineEventsTraceTestCase(TraceTestCase):
"""Repeat the trace tests, but with per-line events skipped"""