diff options
author | Guido van Rossum <guido@python.org> | 2001-08-16 20:41:56 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-08-16 20:41:56 (GMT) |
commit | 501c7c7d0eb8c8fb1a9384092efed0141052f324 (patch) | |
tree | 99b329657928c633cb364d0e357b9ea0c7426662 /Objects/classobject.c | |
parent | 2907fe6ce7376e73d84c8a29dedd37d8b3e4a225 (diff) | |
download | cpython-501c7c7d0eb8c8fb1a9384092efed0141052f324.zip cpython-501c7c7d0eb8c8fb1a9384092efed0141052f324.tar.gz cpython-501c7c7d0eb8c8fb1a9384092efed0141052f324.tar.bz2 |
classobject.c:instancemethod_descr_get(): when a bound method is
assigned to a class variable and then accessed via an instance, it
should not be rebound.
test_descr.py:methods(): test for the condition above.
Diffstat (limited to 'Objects/classobject.c')
-rw-r--r-- | Objects/classobject.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c index 255a432..82eb1d5 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -2196,6 +2196,11 @@ instancemethod_call(PyObject *func, PyObject *arg, PyObject *kw) static PyObject * instancemethod_descr_get(PyObject *meth, PyObject *obj, PyObject *type) { + if (PyMethod_GET_SELF(meth) != NULL) { + /* Don't rebind an already bound method */ + Py_INCREF(meth); + return meth; + } if (obj == Py_None) obj = NULL; return PyMethod_New(PyMethod_GET_FUNCTION(meth), obj, type); |