summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2002-09-11 15:36:32 (GMT)
committerMichael W. Hudson <mwh@python.net>2002-09-11 15:36:32 (GMT)
commit02ff6a99522bf0c734831841661ebd385ae8c417 (patch)
treefdb0a6ffa6b397e39fe09f03bee05fa8a650eb0b /Objects
parent519a342d799a0222ca5290d152ee97d7818a9493 (diff)
downloadcpython-02ff6a99522bf0c734831841661ebd385ae8c417.zip
cpython-02ff6a99522bf0c734831841661ebd385ae8c417.tar.gz
cpython-02ff6a99522bf0c734831841661ebd385ae8c417.tar.bz2
A slight change to SET_LINENO-less tracing.
This makes things a touch more like 2.2. Read the comments in Python/ceval.c for more details.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/frameobject.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index c65ca40..3036ab6 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -17,7 +17,6 @@ static PyMemberDef frame_memberlist[] = {
{"f_globals", T_OBJECT, OFF(f_globals), RO},
{"f_lasti", T_INT, OFF(f_lasti), RO},
{"f_restricted",T_INT, OFF(f_restricted),RO},
- {"f_trace", T_OBJECT, OFF(f_trace)},
{"f_exc_type", T_OBJECT, OFF(f_exc_type)},
{"f_exc_value", T_OBJECT, OFF(f_exc_value)},
{"f_exc_traceback", T_OBJECT, OFF(f_exc_traceback)},
@@ -37,14 +36,49 @@ frame_getlineno(PyFrameObject *f, void *closure)
{
int lineno;
- lineno = PyCode_Addr2Line(f->f_code, f->f_lasti);
+ if (f->f_trace)
+ lineno = f->f_lineno;
+ else
+ lineno = PyCode_Addr2Line(f->f_code, f->f_lasti);
return PyInt_FromLong(lineno);
}
+static PyObject *
+frame_gettrace(PyFrameObject *f, void *closure)
+{
+ PyObject* trace = f->f_trace;
+
+ if (trace == NULL)
+ trace = Py_None;
+
+ Py_INCREF(trace);
+
+ return trace;
+}
+
+static int
+frame_settrace(PyFrameObject *f, PyObject* v, void *closure)
+{
+ /* We rely on f_lineno being accurate when f_trace is set. */
+
+ PyObject* old_value = f->f_trace;
+
+ Py_XINCREF(v);
+ f->f_trace = v;
+
+ if (v != NULL)
+ f->f_lineno = PyCode_Addr2Line(f->f_code, f->f_lasti);
+
+ Py_XDECREF(old_value);
+
+ return 0;
+}
+
static PyGetSetDef frame_getsetlist[] = {
{"f_locals", (getter)frame_getlocals, NULL, NULL},
{"f_lineno", (getter)frame_getlineno, NULL, NULL},
+ {"f_trace", (getter)frame_gettrace, (setter)frame_settrace, NULL},
{0}
};