mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
gh-93061: Mark as artificial: backwards jump after async for (GH-93062)
This commit is contained in:
parent
fc00667247
commit
a458be3263
3 changed files with 55 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue