diff options
-rw-r--r-- | Lib/test/test_descr.py | 2 | ||||
-rw-r--r-- | Objects/classobject.c | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 4d1f817..f524dba 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -862,7 +862,7 @@ def methods(): d2 = D(2) verify(d2.foo() == 2) verify(d2.boo() == 2) - verify(d2.goo() == 2) + verify(d2.goo() == 1) def specials(): # Test operators like __hash__ for which a built-in default exists 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); |