[Stackless-checkins] CVS: slpdev/src/2.3/dev/Python traceback.c, 1.8, 1.9
Christian Tismer
tismer at centera.de
Sun Apr 18 18:45:27 CEST 2004
Update of /home/cvs/slpdev/src/2.3/dev/Python
In directory centera.de:/tmp/cvs-serv31818/Python
Modified Files:
traceback.c
Log Message:
simplified pickling of tracebacks.
They are recursive, again.
I will try to make cPickle stackless, instead.
Removed all patches from tracebackobject.c
Index: traceback.c
===================================================================
RCS file: /home/cvs/slpdev/src/2.3/dev/Python/traceback.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** traceback.c 14 Jan 2004 19:11:08 -0000 1.8
--- traceback.c 18 Apr 2004 16:45:25 -0000 1.9
***************
*** 15,119 ****
int tb_lasti;
int tb_lineno;
- #ifdef STACKLESS
- int tb_is_head; /* helper for pickling */
- #endif
} tracebackobject;
#define OFF(x) offsetof(tracebackobject, x)
- #ifdef STACKLESS
-
- static PyMemberDef tb_memberlist[] = {
- {"tb_next", T_OBJECT, OFF(tb_next), RO},
- {"tb_frame", T_OBJECT, OFF(tb_frame), RO},
- {"tb_lasti", T_INT, OFF(tb_lasti), RO},
- {"tb_lineno", T_INT, OFF(tb_lineno), RO},
- {NULL} /* Sentinel */
- };
-
- static PyObject *
- tb_reduce(tracebackobject * tb)
- {
- PyObject *tup = NULL, *lis;
- tracebackobject *tb_next;
- if (!tb->tb_is_head) {
- tup = Py_BuildValue("(O(Oii))",
- &PyTraceBack_Type,
- tb->tb_frame, tb->tb_lasti, tb->tb_lineno);
- if (tup == NULL) return NULL;
- return tup;
- }
- lis = PyList_New(0);
- if (lis == NULL) return NULL;
- tb_next = tb->tb_next;
- while (tb_next != NULL) {
- if (PyList_Append(lis, (PyObject *) tb_next))
- goto err_exit;
- tb_next = tb_next->tb_next;
- }
-
- tup = Py_BuildValue("(O(OiiO))",
- &PyTraceBack_Type,
- tb->tb_frame, tb->tb_lasti, tb->tb_lineno,
- lis);
-
- err_exit:
- Py_XDECREF(lis);
- return tup;
- }
-
- static PyMethodDef tb_methodlist[] = {
- {"__reduce__", (PyCFunction)tb_reduce, METH_NOARGS, NULL},
- {NULL, NULL}
- };
-
- static tracebackobject *
- newtracebackobject(tracebackobject *next, PyFrameObject *frame);
-
- static
- PyObject *
- traceback_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
- {
- tracebackobject *tb;
- PyFrameObject *frame;
- int lasti, lineno;
- PyObject *lis = NULL;
-
- if (kwds != NULL) {
- PyErr_SetString(PyExc_ValueError, "Keyword parameters not supported for traceback_new");
- return NULL;
- }
- if (!PyArg_ParseTuple(args, "O!ii|O!:traceback",
- PyBaseFrame_Type, &frame,
- &lasti, &lineno,
- &PyList_Type, &lis))
- return NULL;
-
- tb = newtracebackobject(NULL, frame);
- if (tb == NULL)
- return NULL;
-
- if (lis != NULL) {
- int i;
- tracebackobject *tb_curr = tb, *tb_next;
- for (i=0; i < PyList_GET_SIZE(lis); ++i) {
- tb_next = (tracebackobject *) PyList_GET_ITEM(lis, i);
- if (!PyTraceBack_Check(tb_next)) {
- PyErr_SetString(PyExc_TypeError,
- "list of tracebacks expected in traceback()");
- Py_DECREF(tb);
- return NULL;
- }
- tb_curr->tb_next = tb_next;
- tb_curr = tb_next;
- Py_INCREF(tb_next);
- }
- tb->tb_is_head = 1;
- }
- return (PyObject *) tb;
- }
-
- #else
-
static struct memberlist tb_memberlist[] = {
{"tb_next", T_OBJECT, OFF(tb_next)},
--- 15,22 ----
***************
*** 129,133 ****
return PyMember_Get((char *)tb, tb_memberlist, name);
}
- #endif
static void
--- 32,35 ----
***************
*** 173,181 ****
(destructor)tb_dealloc, /*tp_dealloc*/
0, /*tp_print*/
- #ifdef STACKLESS
- 0,
- #else
(getattrfunc)tb_getattr, /*tp_getattr*/
- #endif
0, /*tp_setattr*/
0, /*tp_compare*/
--- 75,79 ----
***************
*** 187,195 ****
0, /* tp_call */
0, /* tp_str */
- #ifdef STACKLESS
- PyObject_GenericGetAttr,
- #else
0, /* tp_getattro */
- #endif
0, /* tp_setattro */
0, /* tp_as_buffer */
--- 85,89 ----
***************
*** 202,223 ****
0, /* tp_iter */
0, /* tp_iternext */
- #ifdef STACKLESS
- tb_methodlist, /* tp_methods */
- tb_memberlist, /* tp_members */
- #else
0, /* tp_methods */
0, /* tp_members */
- #endif
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
- #ifdef STACKLESS
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- traceback_new, /* tp_new */
- #endif
};
--- 96,104 ----
***************
*** 240,246 ****
tb->tb_lineno = PyCode_Addr2Line(frame->f_code,
frame->f_lasti);
- #ifdef STACKLESS
- tb->tb_is_head = 0;
- #endif
PyObject_GC_Track(tb);
}
--- 121,124 ----
***************
*** 261,273 ****
return -1;
tstate->curexc_traceback = (PyObject *)tb;
- #ifdef STACKLESS
- if (oldtb != NULL) {
- oldtb->tb_is_head = 0;
- tb->tb_is_head = 1;
- Py_DECREF(oldtb);
- }
- #else
Py_XDECREF(oldtb);
- #endif
return 0;
}
--- 139,143 ----
_______________________________________________
Stackless-checkins mailing list
Stackless-checkins at stackless.com
http://www.stackless.com/mailman/listinfo/stackless-checkins
More information about the Stackless-checkins
mailing list