mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-42823: Fix frame lineno when frame.f_trace is set (GH-24099)
* Add test for frame.f_lineno with/without tracing. * Make sure that frame.f_lineno is correct regardless of whether frame.f_trace is set. * Update importlib * Add NEWS
This commit is contained in:
parent
e40e2a2cc9
commit
ee9f98d9f4
8 changed files with 1182 additions and 1159 deletions
|
@ -44,7 +44,7 @@ int
|
|||
PyFrame_GetLineNumber(PyFrameObject *f)
|
||||
{
|
||||
assert(f != NULL);
|
||||
if (f->f_trace) {
|
||||
if (f->f_lineno != 0) {
|
||||
return f->f_lineno;
|
||||
}
|
||||
else {
|
||||
|
@ -476,8 +476,8 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno, void *Py_UNUSED(ignore
|
|||
start_block_stack = pop_block(start_block_stack);
|
||||
}
|
||||
|
||||
/* Finally set the new f_lineno and f_lasti and return OK. */
|
||||
f->f_lineno = new_lineno;
|
||||
/* Finally set the new f_lasti and return OK. */
|
||||
f->f_lineno = 0;
|
||||
f->f_lasti = best_addr;
|
||||
return 0;
|
||||
}
|
||||
|
@ -498,11 +498,9 @@ frame_gettrace(PyFrameObject *f, void *closure)
|
|||
static int
|
||||
frame_settrace(PyFrameObject *f, PyObject* v, void *closure)
|
||||
{
|
||||
/* We rely on f_lineno being accurate when f_trace is set. */
|
||||
f->f_lineno = PyFrame_GetLineNumber(f);
|
||||
|
||||
if (v == Py_None)
|
||||
if (v == Py_None) {
|
||||
v = NULL;
|
||||
}
|
||||
Py_XINCREF(v);
|
||||
Py_XSETREF(f->f_trace, v);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue