diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-05-23 18:58:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-23 18:58:53 (GMT) |
commit | f0950585a3723fd674964733ae3ced9217cf9d21 (patch) | |
tree | 75588e66e0d9a94b48363e7d50c38ae6cfa3cb0d /Lib/test/test_sys_settrace.py | |
parent | 96218f774e2b3c5a4ded5f48b22ec97e02043def (diff) | |
download | cpython-f0950585a3723fd674964733ae3ced9217cf9d21.zip cpython-f0950585a3723fd674964733ae3ced9217cf9d21.tar.gz cpython-f0950585a3723fd674964733ae3ced9217cf9d21.tar.bz2 |
gh-93061: Mark as artificial: backwards jump after async for (GH-93062) (GH-93110)
(cherry picked from commit a458be3263b4cb92f3fde726461e8ef44b2a4a9d)
Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_sys_settrace.py')
-rw-r--r-- | Lib/test/test_sys_settrace.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py index 9cc6bcf..162fd83 100644 --- a/Lib/test/test_sys_settrace.py +++ b/Lib/test/test_sys_settrace.py @@ -609,6 +609,58 @@ class TraceTestCase(unittest.TestCase): self.compare_events(doit_async.__code__.co_firstlineno, tracer.events, events) + def test_async_for_backwards_jump_has_no_line(self): + async def arange(n): + for i in range(n): + yield i + async def f(): + async for i in arange(3): + if i > 100: + break # should never be traced + + tracer = self.make_tracer() + coro = f() + try: + sys.settrace(tracer.trace) + coro.send(None) + except Exception: + pass + finally: + sys.settrace(None) + + events = [ + (0, 'call'), + (1, 'line'), + (-3, 'call'), + (-2, 'line'), + (-1, 'line'), + (-1, 'return'), + (1, 'exception'), + (2, 'line'), + (1, 'line'), + (-1, 'call'), + (-2, 'line'), + (-1, 'line'), + (-1, 'return'), + (1, 'exception'), + (2, 'line'), + (1, 'line'), + (-1, 'call'), + (-2, 'line'), + (-1, 'line'), + (-1, 'return'), + (1, 'exception'), + (2, 'line'), + (1, 'line'), + (-1, 'call'), + (-2, 'line'), + (-2, 'return'), + (1, 'exception'), + (1, 'return'), + ] + self.compare_events(f.__code__.co_firstlineno, + tracer.events, events) + def test_21_repeated_pass(self): def func(): pass |