From 4f4c246d423c5969512a19bad5ed1036a3121329 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 16 Jun 2007 19:04:52 +0200 Subject: [PATCH] [svn] Fix _debugger module. --HG-- branch : trunk --- jinja/_debugger.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/jinja/_debugger.c b/jinja/_debugger.c index 111d825..f58aace 100644 --- a/jinja/_debugger.c +++ b/jinja/_debugger.c @@ -20,23 +20,29 @@ /** * set the tb_next attribute of a traceback object */ -PyObject* +static PyObject * tb_set_next(PyObject *self, PyObject *args) { - PyObject *tb, *next; + PyTracebackObject *tb, *old; + PyObject *next; - if (!PyArg_ParseTuple(args, "OO", &tb, &next)) + if (!PyArg_ParseTuple(args, "O!O:tb_set_next", &tb, PyTraceBack_Type, &next)) return NULL; - if (!(PyTraceBack_Check(tb) && (PyTraceBack_Check(next) || - next == Py_None))) { - PyErr_SetString(PyExc_TypeError, "traceback object required."); + if (next == Py_None) { + next = NULL; + } else if (!PyTraceBack_Check(next)) { + PyErr_SetString(PyExc_TypeError, + "tb_set_next arg 2 must be traceback or None"); return NULL; + } else { + Py_INCREF(next); } - ((PyTracebackObject*)tb)->tb_next = next; + old = tb->tb_next; + tb->tb_next = (PyTracebackObject *)next; + Py_XDECREF(old); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } @@ -52,7 +58,7 @@ static PyMethodDef module_methods[] = { PyMODINIT_FUNC init_debugger(void) { - PyObject *module = Py_InitModule3("_debugger", module_methods, ""); + PyObject *module = Py_InitModule3("jinja._debugger", module_methods, ""); if (!module) return; } -- 2.26.2