[Python-checkins] CVS: python/dist/src/Objects classobject.c,2.136,2.137
Guido van Rossum
gvanrossum@users.sourceforge.net
Thu, 16 Aug 2001 13:41:58 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv14035/Objects
Modified Files:
classobject.c
Log Message:
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.
Index: classobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v
retrieving revision 2.136
retrieving revision 2.137
diff -C2 -d -r2.136 -r2.137
*** classobject.c 2001/08/15 17:52:31 2.136
--- classobject.c 2001/08/16 20:41:56 2.137
***************
*** 2197,2200 ****
--- 2197,2205 ----
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;