]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
While I was modifying test_trace, it threw an exception when I accidentally
authorJeffrey Yasskin <jyasskin@gmail.com>
Mon, 18 May 2009 21:14:54 +0000 (21:14 +0000)
committerJeffrey Yasskin <jyasskin@gmail.com>
Mon, 18 May 2009 21:14:54 +0000 (21:14 +0000)
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.

Lib/test/test_trace.py
Objects/frameobject.c

index b5db9a7a01f5a19dab5744d37910f40c78bc35b7..a8f51638399194aadb98e80623ef8259db48e124 100644 (file)
@@ -471,7 +471,7 @@ class JumpTracer:
     def trace(self, frame, event, arg):
         if not self.done and frame.f_code == self.function.func_code:
             firstLine = frame.f_code.co_firstlineno
-            if frame.f_lineno == firstLine + self.jumpFrom:
+            if event == 'line' and frame.f_lineno == firstLine + self.jumpFrom:
                 # Cope with non-integer self.jumpTo (because of
                 # no_jump_to_non_integers below).
                 try:
index 7a9d40d8965a0f6513a2dc803b5d86a15335a299..5e54585f67bc2828fb73a60cc0c65dc93bca486d 100644 (file)
@@ -127,7 +127,8 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
        if (!f->f_trace)
        {
                PyErr_Format(PyExc_ValueError,
-                            "f_lineno can only be set by a trace function");
+                            "f_lineno can only be set by a"
+                            " line trace function");
                return -1;
        }