summaryrefslogtreecommitdiffstats
path: root/Objects/cellobject.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-03-18 07:59:59 (GMT)
committerGeorg Brandl <georg@python.org>2006-03-18 07:59:59 (GMT)
commitabd1ff8f1f6f2840345756081837994fdefaa52b (patch)
tree298b063bb5505e62081b2267f4480d7728712481 /Objects/cellobject.c
parent237037beb53822cacce21e20d624bb74977dadcb (diff)
downloadcpython-abd1ff8f1f6f2840345756081837994fdefaa52b.zip
cpython-abd1ff8f1f6f2840345756081837994fdefaa52b.tar.gz
cpython-abd1ff8f1f6f2840345756081837994fdefaa52b.tar.bz2
Previously, Python code had no easy way to access the contents of a
cell object. Now, a ``cell_contents`` attribute has been added (closes patch #1170323).
Diffstat (limited to 'Objects/cellobject.c')
-rw-r--r--Objects/cellobject.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/Objects/cellobject.c b/Objects/cellobject.c
index 3b87093..9704403 100644
--- a/Objects/cellobject.c
+++ b/Objects/cellobject.c
@@ -86,6 +86,18 @@ cell_clear(PyCellObject *op)
return 0;
}
+static PyObject *
+cell_get_contents(PyCellObject *op, void *closure)
+{
+ Py_XINCREF(op->ob_ref);
+ return op->ob_ref;
+}
+
+static PyGetSetDef cell_getsetlist[] = {
+ {"cell_contents", (getter)cell_get_contents, NULL},
+ {NULL} /* sentinel */
+};
+
PyTypeObject PyCell_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
@@ -111,4 +123,11 @@ PyTypeObject PyCell_Type = {
0, /* tp_doc */
(traverseproc)cell_traverse, /* tp_traverse */
(inquiry)cell_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ cell_getsetlist, /* tp_getset */
};