summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-12-13 02:57:25 (GMT)
committerGuido van Rossum <guido@python.org>1996-12-13 02:57:25 (GMT)
commitfbcfd52a9ab413fdf4e2ffadde727cd378982de6 (patch)
tree74e5e2ddb78181506cd361ce213789fc3c3b47d6 /Modules
parentd16ddb610a8f09883303ee87c1609bf3bd8a40a8 (diff)
downloadcpython-fbcfd52a9ab413fdf4e2ffadde727cd378982de6.zip
cpython-fbcfd52a9ab413fdf4e2ffadde727cd378982de6.tar.gz
cpython-fbcfd52a9ab413fdf4e2ffadde727cd378982de6.tar.bz2
Added the example "thin ice" from the extensions manual.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/xxmodule.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/Modules/xxmodule.c b/Modules/xxmodule.c
index e21ba9c..465da68 100644
--- a/Modules/xxmodule.c
+++ b/Modules/xxmodule.c
@@ -185,12 +185,36 @@ xx_new(self, args)
return (PyObject *)rv;
}
+/* Example with subtle bug from extensions manual ("Thin Ice"). */
+
+static PyObject *
+xx_bug(self, args)
+ PyObject *self;
+ PyObject *args;
+{
+ PyObject *list, *item;
+
+ if (!PyArg_ParseTuple(args, "O", &list))
+ return NULL;
+
+ item = PyList_GetItem(list, 0);
+ /* Py_INCREF(item); */
+ PyList_SetItem(list, 1, PyInt_FromLong(0L));
+ PyObject_Print(item, stdout, 0);
+ printf("\n");
+ /* Py_DECREF(item); */
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
/* List of functions defined in the module */
static PyMethodDef xx_methods[] = {
{"foo", xx_foo, 1},
{"new", xx_new, 1},
+ {"bug", xx_bug, 1},
{NULL, NULL} /* sentinel */
};