diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-02-20 01:02:57 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-02-20 01:02:57 (GMT) |
commit | 23d7f12ffb8983fa670ef289a03c3d55153f37ce (patch) | |
tree | 23eafcf933a4f63c8092e5ad9171000168ffd169 /Modules/_functoolsmodule.c | |
parent | 8eb1269c346fa860acce9459c0bed065ffccd3ce (diff) | |
download | cpython-23d7f12ffb8983fa670ef289a03c3d55153f37ce.zip cpython-23d7f12ffb8983fa670ef289a03c3d55153f37ce.tar.gz cpython-23d7f12ffb8983fa670ef289a03c3d55153f37ce.tar.bz2 |
use new generic __dict__ descriptor implementations
Diffstat (limited to 'Modules/_functoolsmodule.c')
-rw-r--r-- | Modules/_functoolsmodule.c | 38 |
1 files changed, 1 insertions, 37 deletions
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index 0882d36..3ff07bc 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -155,44 +155,8 @@ static PyMemberDef partial_memberlist[] = { {NULL} /* Sentinel */ }; -static PyObject * -partial_get_dict(partialobject *pto) -{ - if (pto->dict == NULL) { - pto->dict = PyDict_New(); - if (pto->dict == NULL) - return NULL; - } - Py_INCREF(pto->dict); - return pto->dict; -} - -static int -partial_set_dict(partialobject *pto, PyObject *value) -{ - PyObject *tmp; - - /* It is illegal to del p.__dict__ */ - if (value == NULL) { - PyErr_SetString(PyExc_TypeError, - "a partial object's dictionary may not be deleted"); - return -1; - } - /* Can only set __dict__ to a dictionary */ - if (!PyDict_Check(value)) { - PyErr_SetString(PyExc_TypeError, - "setting partial object's dictionary to a non-dict"); - return -1; - } - tmp = pto->dict; - Py_INCREF(value); - pto->dict = value; - Py_XDECREF(tmp); - return 0; -} - static PyGetSetDef partial_getsetlist[] = { - {"__dict__", (getter)partial_get_dict, (setter)partial_set_dict}, + {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict}, {NULL} /* Sentinel */ }; |