mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Armin Rigo's fix & test for
[ 729622 ] line tracing hook errors with massaging from me to integrate test into test suite.
This commit is contained in:
parent
572f5233f0
commit
58ee2af48e
2 changed files with 32 additions and 10 deletions
|
|
@ -221,6 +221,27 @@ class RaisingTraceFuncTestCase(unittest.TestCase):
|
||||||
def test_exception(self):
|
def test_exception(self):
|
||||||
self.run_test_for_event('exception')
|
self.run_test_for_event('exception')
|
||||||
|
|
||||||
|
def test_trash_stack(self):
|
||||||
|
def f():
|
||||||
|
for i in range(5):
|
||||||
|
print i # line tracing will raise an exception at this line
|
||||||
|
|
||||||
|
def g(frame, why, extra):
|
||||||
|
if (why == 'line' and
|
||||||
|
frame.f_lineno == f.func_code.co_firstlineno + 2):
|
||||||
|
raise RuntimeError, "i am crashing"
|
||||||
|
return g
|
||||||
|
|
||||||
|
sys.settrace(g)
|
||||||
|
try:
|
||||||
|
f()
|
||||||
|
except RuntimeError:
|
||||||
|
# the test is really that this doesn't segfault:
|
||||||
|
import gc
|
||||||
|
gc.collect()
|
||||||
|
else:
|
||||||
|
self.fail("exception not propagated")
|
||||||
|
|
||||||
|
|
||||||
# 'Jump' tests: assigning to frame.f_lineno within a trace function
|
# 'Jump' tests: assigning to frame.f_lineno within a trace function
|
||||||
# moves the execution position - it's how debuggers implement a Jump
|
# moves the execution position - it's how debuggers implement a Jump
|
||||||
|
|
|
||||||
|
|
@ -819,18 +819,19 @@ eval_frame(PyFrameObject *f)
|
||||||
for expository comments */
|
for expository comments */
|
||||||
f->f_stacktop = stack_pointer;
|
f->f_stacktop = stack_pointer;
|
||||||
|
|
||||||
if (maybe_call_line_trace(tstate->c_tracefunc,
|
err = maybe_call_line_trace(tstate->c_tracefunc,
|
||||||
tstate->c_traceobj,
|
tstate->c_traceobj,
|
||||||
f, &instr_lb, &instr_ub)) {
|
f, &instr_lb, &instr_ub);
|
||||||
/* trace function raised an exception */
|
|
||||||
why = WHY_EXCEPTION;
|
|
||||||
goto on_error;
|
|
||||||
}
|
|
||||||
/* Reload possibly changed frame fields */
|
/* Reload possibly changed frame fields */
|
||||||
JUMPTO(f->f_lasti);
|
JUMPTO(f->f_lasti);
|
||||||
stack_pointer = f->f_stacktop;
|
if (f->f_stacktop != NULL) {
|
||||||
assert(stack_pointer != NULL);
|
stack_pointer = f->f_stacktop;
|
||||||
f->f_stacktop = NULL;
|
f->f_stacktop = NULL;
|
||||||
|
}
|
||||||
|
if (err) {
|
||||||
|
/* trace function raised an exception */
|
||||||
|
goto on_error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extract opcode and argument */
|
/* Extract opcode and argument */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue