allow history to work in webkit browsers
[gae-samples.git] / python27 / guestbook / jinja2 / _debugsupport.c
blobe756d8e1ac9b8d1b0e5ece2d36763c66fdafc0d3
1 /**
2 * jinja2._debugsupport
3 * ~~~~~~~~~~~~~~~~~~~~
5 * C implementation of `tb_set_next`.
7 * :copyright: (c) 2010 by the Jinja Team.
8 * :license: BSD.
9 */
11 #include <Python.h>
14 static PyObject*
15 tb_set_next(PyObject *self, PyObject *args)
17 PyTracebackObject *tb, *old;
18 PyObject *next;
20 if (!PyArg_ParseTuple(args, "O!O:tb_set_next", &PyTraceBack_Type, &tb, &next))
21 return NULL;
22 if (next == Py_None)
23 next = NULL;
24 else if (!PyTraceBack_Check(next)) {
25 PyErr_SetString(PyExc_TypeError,
26 "tb_set_next arg 2 must be traceback or None");
27 return NULL;
29 else
30 Py_INCREF(next);
32 old = tb->tb_next;
33 tb->tb_next = (PyTracebackObject*)next;
34 Py_XDECREF(old);
36 Py_INCREF(Py_None);
37 return Py_None;
40 static PyMethodDef module_methods[] = {
41 {"tb_set_next", (PyCFunction)tb_set_next, METH_VARARGS,
42 "Set the tb_next member of a traceback object."},
43 {NULL, NULL, 0, NULL} /* Sentinel */
47 #if PY_MAJOR_VERSION < 3
49 #ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
50 #define PyMODINIT_FUNC void
51 #endif
52 PyMODINIT_FUNC
53 init_debugsupport(void)
55 Py_InitModule3("jinja2._debugsupport", module_methods, "");
58 #else /* Python 3.x module initialization */
60 static struct PyModuleDef module_definition = {
61 PyModuleDef_HEAD_INIT,
62 "jinja2._debugsupport",
63 NULL,
64 -1,
65 module_methods,
66 NULL,
67 NULL,
68 NULL,
69 NULL
72 PyMODINIT_FUNC
73 PyInit__debugsupport(void)
75 return PyModule_Create(&module_definition);
78 #endif