bpo-30486: Allow setting cell value (#1840)

The cell_contents attribute of the cell object is now writable.
This commit is contained in:
Lisa Roach 2017-06-08 04:43:26 -07:00 committed by Serhiy Storchaka
parent 6cca5c8459
commit 64505a1f6c
4 changed files with 41 additions and 4 deletions

View file

@ -140,8 +140,17 @@ cell_get_contents(PyCellObject *op, void *closure)
return op->ob_ref;
}
int
cell_set_contents(PyCellObject *op, PyObject *obj)
{
Py_XINCREF(obj);
Py_XSETREF(op->ob_ref, obj);
return 0;
}
static PyGetSetDef cell_getsetlist[] = {
{"cell_contents", (getter)cell_get_contents, NULL},
{"cell_contents", (getter)cell_get_contents,
(setter)cell_set_contents, NULL},
{NULL} /* sentinel */
};