summaryrefslogtreecommitdiffstats
path: root/Objects/classobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-10-22 02:00:09 (GMT)
committerGuido van Rossum <guido@python.org>2001-10-22 02:00:09 (GMT)
commit56ff387a7e625a692851e2e5ffdea096b72831f7 (patch)
tree6b5d86b12a0d5005ff31fb7ced375262bbbbe597 /Objects/classobject.c
parent51c18166bb55ff8ed72f447997bcb38574531112 (diff)
downloadcpython-56ff387a7e625a692851e2e5ffdea096b72831f7.zip
cpython-56ff387a7e625a692851e2e5ffdea096b72831f7.tar.gz
cpython-56ff387a7e625a692851e2e5ffdea096b72831f7.tar.bz2
Fix for SF bug #472940: can't getattr() attribute shown by dir()
There really isn't a good reason for instance method objects to have their own __dict__, __doc__ and __name__ properties that just delegate the request to the function (callable); the default attribute behavior already does this. The test suite had to be fixed because the error changes from TypeError to AttributeError.
Diffstat (limited to 'Objects/classobject.c')
-rw-r--r--Objects/classobject.c29
1 files changed, 1 insertions, 28 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c
index 57de8e9..622ca58 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -2019,33 +2019,6 @@ static PyMemberDef instancemethod_memberlist[] = {
{NULL} /* Sentinel */
};
-/* __dict__, __doc__ and __name__ are retrieved from im_func */
-
-static PyObject *
-im_get_dict(PyMethodObject *im)
-{
- return PyObject_GetAttrString(im->im_func, "__dict__");
-}
-
-static PyObject *
-im_get_doc(PyMethodObject *im)
-{
- return PyObject_GetAttrString(im->im_func, "__doc__");
-}
-
-static PyObject *
-im_get_name(PyMethodObject *im)
-{
- return PyObject_GetAttrString(im->im_func, "__name__");
-}
-
-static PyGetSetDef instancemethod_getsetlist[] = {
- {"__dict__", (getter)im_get_dict, NULL, "same as im_func.__dict__"},
- {"__doc__", (getter)im_get_doc, NULL, "same as im_func.__doc__"},
- {"__name__", (getter)im_get_name, NULL, "same as im_func.__name__"},
- {NULL} /* Sentinel */
-};
-
/* The getattr() implementation for PyMethod objects is similar to
PyObject_GenericGetAttr(), but instead of looking in __dict__ it
asks im_self for the attribute. Then the error handling is a bit
@@ -2350,7 +2323,7 @@ PyTypeObject PyMethod_Type = {
0, /* tp_iternext */
0, /* tp_methods */
instancemethod_memberlist, /* tp_members */
- instancemethod_getsetlist, /* tp_getset */
+ 0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
instancemethod_descr_get, /* tp_descr_get */