]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Previously, Python code had no easy way to access the contents of a
authorGeorg Brandl <georg@python.org>
Sat, 18 Mar 2006 07:59:59 +0000 (07:59 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 18 Mar 2006 07:59:59 +0000 (07:59 +0000)
cell object. Now, a ``cell_contents`` attribute has been added
(closes patch #1170323).

Misc/NEWS
Objects/cellobject.c

index 98b21625df157baa31dc88bb4316924c386ed64c..a9667e3b5bab8ff368b4b3394402afb4bbb50672 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,10 @@ What's New in Python 2.5 alpha 1?
 Core and builtins
 -----------------
 
+- 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).
+
 - Patch #1123430: Python's small-object allocator now returns an arena to
   the system ``free()`` when all memory within an arena becomes unused
   again.  Prior to Python 2.5, arenas (256KB chunks of memory) were never
index 3b870934dc10c56aeebd2dcb4f2830aff2626fd1..97044032fcc73c95ff5ce03df22a5c8429fd6dfc 100644 (file)
@@ -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 */
 };