[Python-checkins] CVS: python/dist/src/Objects classobject.c,2.136,2.137

Guido van Rossum gvanrossum@users.sourceforge.net
2001年8月16日 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;

AltStyle によって変換されたページ (->オリジナル) /