use new generic __dict__ descriptor implementations
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 @@
{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 */
};
diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c
index 3bce1a5..b30bbb6 100644
--- a/Modules/_io/iobase.c
+++ b/Modules/_io/iobase.c
@@ -159,19 +159,6 @@
return PyBool_FromLong(IS_CLOSED(self));
}
-static PyObject *
-iobase_get_dict(PyObject *self)
-{
- PyObject **dictptr = _PyObject_GetDictPtr(self);
- PyObject *dict;
- assert(dictptr);
- dict = *dictptr;
- if (dict == NULL)
- dict = *dictptr = PyDict_New();
- Py_XINCREF(dict);
- return dict;
-}
-
PyObject *
_PyIOBase_check_closed(PyObject *self, PyObject *args)
{
@@ -714,7 +701,7 @@
};
static PyGetSetDef iobase_getset[] = {
- {"__dict__", (getter)iobase_get_dict, NULL, NULL},
+ {"__dict__", PyObject_GenericGetDict, NULL, NULL},
{"closed", (getter)iobase_closed_get, NULL, NULL},
{NULL}
};