Skip to content

Commit 61328ee

Browse files
committed
While I was modifying test_trace, it threw an exception when I accidentally
made it try to set the line number from the trace callback for a 'call' event. This patch makes the error message a little more helpful in that case, and makes it a little less likely that a future editor will make the same mistake in test_trace.
1 parent fceb5d4 commit 61328ee

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Lib/test/test_trace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ def __init__(self, function):
471471
def trace(self, frame, event, arg):
472472
if not self.done and frame.f_code == self.function.func_code:
473473
firstLine = frame.f_code.co_firstlineno
474-
if frame.f_lineno == firstLine + self.jumpFrom:
474+
if event == 'line' and frame.f_lineno == firstLine + self.jumpFrom:
475475
# Cope with non-integer self.jumpTo (because of
476476
# no_jump_to_non_integers below).
477477
try:

Objects/frameobject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
127127
if (!f->f_trace)
128128
{
129129
PyErr_Format(PyExc_ValueError,
130-
"f_lineno can only be set by a trace function");
130+
"f_lineno can only be set by a"
131+
" line trace function");
131132
return -1;
132133
}
133134

0 commit comments

Comments
 (0)