summaryrefslogtreecommitdiff
path: root/coverage
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-01-06 10:13:54 -0500
committerNed Batchelder <ned@nedbatchelder.com>2021-01-10 09:46:18 -0500
commit7e5e28f1aba87c10b96d0ae1244352f4c520aedc (patch)
tree51ac84ec33e878c26cbbd47cf92ed2545fbb5c54 /coverage
parent5c3d0946821118ad11f5b10753c638a446f24bfe (diff)
downloadpython-coveragepy-git-7e5e28f1aba87c10b96d0ae1244352f4c520aedc.tar.gz
Use the supported way to get a C frame's lineno
See https://bugs.python.org/issue42823 for discussion.
Diffstat (limited to 'coverage')
-rw-r--r--coverage/ctracer/tracer.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/coverage/ctracer/tracer.c b/coverage/ctracer/tracer.c
index 04552352..00e4218d 100644
--- a/coverage/ctracer/tracer.c
+++ b/coverage/ctracer/tracer.c
@@ -305,7 +305,7 @@ CTracer_check_missing_return(CTracer *self, PyFrameObject *frame)
goto error;
}
}
- SHOWLOG(self->pdata_stack->depth, frame->f_lineno, frame->f_code->co_filename, "missedreturn");
+ SHOWLOG(self->pdata_stack->depth, PyFrame_GetLineNumber(frame), frame->f_code->co_filename, "missedreturn");
self->pdata_stack->depth--;
self->pcur_entry = &self->pdata_stack->stack[self->pdata_stack->depth];
}
@@ -529,13 +529,13 @@ CTracer_handle_call(CTracer *self, PyFrameObject *frame)
self->pcur_entry->file_data = file_data;
self->pcur_entry->file_tracer = file_tracer;
- SHOWLOG(self->pdata_stack->depth, frame->f_lineno, filename, "traced");
+ SHOWLOG(self->pdata_stack->depth, PyFrame_GetLineNumber(frame), filename, "traced");
}
else {
Py_XDECREF(self->pcur_entry->file_data);
self->pcur_entry->file_data = NULL;
self->pcur_entry->file_tracer = Py_None;
- SHOWLOG(self->pdata_stack->depth, frame->f_lineno, filename, "skipped");
+ SHOWLOG(self->pdata_stack->depth, PyFrame_GetLineNumber(frame), filename, "skipped");
}
self->pcur_entry->disposition = disposition;
@@ -552,7 +552,7 @@ CTracer_handle_call(CTracer *self, PyFrameObject *frame)
self->pcur_entry->last_line = -frame->f_code->co_firstlineno;
}
else {
- self->pcur_entry->last_line = frame->f_lineno;
+ self->pcur_entry->last_line = PyFrame_GetLineNumber(frame);
}
ok:
@@ -633,7 +633,7 @@ CTracer_handle_line(CTracer *self, PyFrameObject *frame)
STATS( self->stats.lines++; )
if (self->pdata_stack->depth >= 0) {
- SHOWLOG(self->pdata_stack->depth, frame->f_lineno, frame->f_code->co_filename, "line");
+ SHOWLOG(self->pdata_stack->depth, PyFrame_GetLineNumber(frame), frame->f_code->co_filename, "line");
if (self->pcur_entry->file_data) {
int lineno_from = -1;
int lineno_to = -1;
@@ -655,7 +655,7 @@ CTracer_handle_line(CTracer *self, PyFrameObject *frame)
}
}
else {
- lineno_from = lineno_to = frame->f_lineno;
+ lineno_from = lineno_to = PyFrame_GetLineNumber(frame);
}
if (lineno_from != -1) {
@@ -744,7 +744,7 @@ CTracer_handle_return(CTracer *self, PyFrameObject *frame)
}
/* Pop the stack. */
- SHOWLOG(self->pdata_stack->depth, frame->f_lineno, frame->f_code->co_filename, "return");
+ SHOWLOG(self->pdata_stack->depth, PyFrame_GetLineNumber(frame), frame->f_code->co_filename, "return");
self->pdata_stack->depth--;
self->pcur_entry = &self->pdata_stack->stack[self->pdata_stack->depth];
}
@@ -807,14 +807,14 @@ CTracer_trace(CTracer *self, PyFrameObject *frame, int what, PyObject *arg_unuse
#if WHAT_LOG
if (what <= (int)(sizeof(what_sym)/sizeof(const char *))) {
ascii = MyText_AS_BYTES(frame->f_code->co_filename);
- printf("trace: %s @ %s %d\n", what_sym[what], MyBytes_AS_STRING(ascii), frame->f_lineno);
+ printf("trace: %s @ %s %d\n", what_sym[what], MyBytes_AS_STRING(ascii), PyFrame_GetLineNumber(frame));
Py_DECREF(ascii);
}
#endif
#if TRACE_LOG
ascii = MyText_AS_BYTES(frame->f_code->co_filename);
- if (strstr(MyBytes_AS_STRING(ascii), start_file) && frame->f_lineno == start_line) {
+ if (strstr(MyBytes_AS_STRING(ascii), start_file) && PyFrame_GetLineNumber(frame) == start_line) {
logging = TRUE;
}
Py_DECREF(ascii);
@@ -931,7 +931,7 @@ CTracer_call(CTracer *self, PyObject *args, PyObject *kwds)
#if WHAT_LOG
ascii = MyText_AS_BYTES(frame->f_code->co_filename);
- printf("pytrace: %s @ %s %d\n", what_sym[what], MyBytes_AS_STRING(ascii), frame->f_lineno);
+ printf("pytrace: %s @ %s %d\n", what_sym[what], MyBytes_AS_STRING(ascii), PyFrame_GetLineNumber(frame));
Py_DECREF(ascii);
#endif