]> granicus.if.org Git - python/commitdiff
The fix in ceval.c 2.386 allows iteration-by-iteration line tracing even in
authorArmin Rigo <arigo@tunes.org>
Mon, 22 Mar 2004 19:30:39 +0000 (19:30 +0000)
committerArmin Rigo <arigo@tunes.org>
Mon, 22 Mar 2004 19:30:39 +0000 (19:30 +0000)
single-line loops.

Lib/test/test_trace.py

index 6aac8df8ae6c76101260e23f7effc3e9649eb355..f85c669630216d8b231cca19d4f0e26f4a6dd3df 100644 (file)
@@ -165,6 +165,27 @@ tightloop_example.events = [(0, 'call'),
                             (7, 'line'),
                             (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:
     def __init__(self):
         self.events = []
@@ -220,6 +241,8 @@ class TraceTestCase(unittest.TestCase):
         self.run_test(ireturn_example)
     def test_11_tightloop(self):
         self.run_test(tightloop_example)
+    def test_12_tighterloop(self):
+        self.run_test(tighterloop_example)
 
 class RaisingTraceFuncTestCase(unittest.TestCase):
     def trace(self, frame, event, arg):