Commit 70693382 authored by Armin Rigo's avatar Armin Rigo

The fix in ceval.c 2.386 allows iteration-by-iteration line tracing even in

single-line loops.
parent bf57a145
...@@ -165,6 +165,27 @@ tightloop_example.events = [(0, 'call'), ...@@ -165,6 +165,27 @@ tightloop_example.events = [(0, 'call'),
(7, 'line'), (7, 'line'),
(7, 'return')] (7, 'return')]
def tighterloop_example():
items = range(1, 4)
try:
i = 0
while 1: i = items[i]
except IndexError:
pass
tighterloop_example.events = [(0, 'call'),
(1, 'line'),
(2, 'line'),
(3, 'line'),
(4, 'line'),
(4, 'line'),
(4, 'line'),
(4, 'line'),
(4, 'exception'),
(5, 'line'),
(6, 'line'),
(6, 'return')]
class Tracer: class Tracer:
def __init__(self): def __init__(self):
self.events = [] self.events = []
...@@ -220,6 +241,8 @@ class TraceTestCase(unittest.TestCase): ...@@ -220,6 +241,8 @@ class TraceTestCase(unittest.TestCase):
self.run_test(ireturn_example) self.run_test(ireturn_example)
def test_11_tightloop(self): def test_11_tightloop(self):
self.run_test(tightloop_example) self.run_test(tightloop_example)
def test_12_tighterloop(self):
self.run_test(tighterloop_example)
class RaisingTraceFuncTestCase(unittest.TestCase): class RaisingTraceFuncTestCase(unittest.TestCase):
def trace(self, frame, event, arg): def trace(self, frame, event, arg):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment