diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-02-04 21:45:05 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-02-04 21:45:05 (GMT) |
commit | 6fd03bb6070586a3b069c90cf3892ba7573d6bf5 (patch) | |
tree | c6ac731d3091f28f849d504bb135a621207b03b8 /Lib/test | |
parent | 578a8caf43ae0d52b37444754adf6f4c404a123c (diff) | |
download | cpython-6fd03bb6070586a3b069c90cf3892ba7573d6bf5.zip cpython-6fd03bb6070586a3b069c90cf3892ba7573d6bf5.tar.gz cpython-6fd03bb6070586a3b069c90cf3892ba7573d6bf5.tar.bz2 |
#1750076: Debugger did not step on every iteration of a while statement.
The mapping between bytecode offsets and source lines (lnotab) did not contain
an entry for the beginning of the loop.
Now it does, and the lnotab can be a bit larger:
in particular, several statements on the same line generate several entries.
However, this does not bother the settrace function, which will trigger only
one 'line' event.
The lnotab seems to be exactly the same as with python2.4.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_trace.py | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py index 144fc66..7f7db33 100644 --- a/Lib/test/test_trace.py +++ b/Lib/test/test_trace.py @@ -252,14 +252,16 @@ class TraceTestCase(unittest.TestCase): "\n".join(difflib.ndiff([str(x) for x in expected_events], [str(x) for x in events]))) - - def run_test(self, func): + def run_and_compare(self, func, events): tracer = Tracer() sys.settrace(tracer.trace) func() sys.settrace(None) self.compare_events(func.func_code.co_firstlineno, - tracer.events, func.events) + tracer.events, events) + + def run_test(self, func): + self.run_and_compare(func, func.events) def run_test2(self, func): tracer = Tracer() @@ -321,6 +323,49 @@ class TraceTestCase(unittest.TestCase): self.compare_events(generator_example.__code__.co_firstlineno, tracer.events, generator_example.events) + def test_14_onliner_if(self): + def onliners(): + if True: False + else: True + return 0 + self.run_and_compare( + onliners, + [(0, 'call'), + (1, 'line'), + (3, 'line'), + (3, 'return')]) + + def test_15_loops(self): + # issue1750076: "while" expression is skipped by debugger + def for_example(): + for x in range(2): + pass + self.run_and_compare( + for_example, + [(0, 'call'), + (1, 'line'), + (2, 'line'), + (1, 'line'), + (2, 'line'), + (1, 'line'), + (1, 'return')]) + + def while_example(): + # While expression should be traced on every loop + x = 2 + while x > 0: + x -= 1 + self.run_and_compare( + while_example, + [(0, 'call'), + (2, 'line'), + (3, 'line'), + (4, 'line'), + (3, 'line'), + (4, 'line'), + (3, 'line'), + (3, 'return')]) + class RaisingTraceFuncTestCase(unittest.TestCase): def trace(self, frame, event, arg): """A trace function that raises an exception in response to a |