mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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.
This commit is contained in:
parent
2907fe6ce7
commit
501c7c7d0e
2 changed files with 6 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue