diff options
author | Jeffrey Yasskin <jyasskin@gmail.com> | 2009-05-20 17:57:57 (GMT) |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@gmail.com> | 2009-05-20 17:57:57 (GMT) |
commit | c8d30fec16e8ed7708bddfad8af03728ae2b9e4d (patch) | |
tree | b5a578e18254b37828d32350b3099fa96f4053ed /Lib | |
parent | cf4ad76a0a429f8cc548aa4dc1d20a37a1fb3fb6 (diff) | |
download | cpython-c8d30fec16e8ed7708bddfad8af03728ae2b9e4d.zip cpython-c8d30fec16e8ed7708bddfad8af03728ae2b9e4d.tar.gz cpython-c8d30fec16e8ed7708bddfad8af03728ae2b9e4d.tar.bz2 |
Fix issue #1689458 by teaching frame_setlineno how to jump to the first line of
a code object.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_trace.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py index a8f5163..f5b8dbf 100644 --- a/Lib/test/test_trace.py +++ b/Lib/test/test_trace.py @@ -740,6 +740,27 @@ class JumpTestCase(unittest.TestCase): def test_19_no_jump_without_trace_function(self): no_jump_without_trace_function() + def test_jump_to_firstlineno(self): + # This tests that PDB can jump back to the first line in a + # file. See issue #1689458. It can only be triggered in a + # function call if the function is defined on a single line. + code = compile(""" +# Comments don't count. +output.append(2) # firstlineno is here. +output.append(3) +output.append(4) +""", "<fake module>", "exec") + class fake_function: + func_code = code + jump = (2, 0) + tracer = JumpTracer(fake_function) + sys.settrace(tracer.trace) + namespace = {"output": []} + exec code in namespace + sys.settrace(None) + self.compare_jump_output([2, 3, 2, 3, 4], namespace["output"]) + + def test_main(): test_support.run_unittest( TraceTestCase, |