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

Guido van Rossum gvanrossum@users.sourceforge.net
2001年10月17日 13:26:40 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv10990
Modified Files:
	classobject.c 
Log Message:
Protect references to tp_descr_get and tp_dict with the appropriate test:
PyType_HasFeature(t, Py_TPFLAGS_HAVE_CLASS).
Index: classobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v
retrieving revision 2.151
retrieving revision 2.152
diff -C2 -d -r2.151 -r2.152
*** classobject.c	2001年09月30日 05:58:41	2.151
--- classobject.c	2001年10月17日 20:26:38	2.152
***************
*** 5,8 ****
--- 5,11 ----
 #include "structmember.h"
 
+ #define TP_DESCR_GET(t) \
+ (PyType_HasFeature(t, Py_TPFLAGS_HAVE_CLASS) ? (t)->tp_descr_get : NULL)
+ 
 
 /* Forward */
***************
*** 233,237 ****
 		return NULL;
 	}
! 	f = v->ob_type->tp_descr_get;
 	if (f == NULL)
 		Py_INCREF(v);
--- 236,240 ----
 		return NULL;
 	}
! 	f = TP_DESCR_GET(v->ob_type);
 	if (f == NULL)
 		Py_INCREF(v);
***************
*** 694,698 ****
 	if (v != NULL) {
 		Py_INCREF(v);
! 		f = v->ob_type->tp_descr_get;
 		if (f != NULL) {
 			PyObject *w = f(v, (PyObject *)inst,
--- 697,701 ----
 	if (v != NULL) {
 		Py_INCREF(v);
! 		f = TP_DESCR_GET(v->ob_type);
 		if (f != NULL) {
 			PyObject *w = f(v, (PyObject *)inst,
***************
*** 2055,2070 ****
 	PyMethodObject *im = (PyMethodObject *)obj;
 	PyTypeObject *tp = obj->ob_type;
! 	PyObject *descr, *res;
! 	descrgetfunc f;
 
! 	if (tp->tp_dict == NULL) {
! 		if (PyType_Ready(tp) < 0)
! 			return NULL;
 	}
 
- 	descr = _PyType_Lookup(tp, name);
 	f = NULL;
 	if (descr != NULL) {
! 		f = descr->ob_type->tp_descr_get;
 		if (f != NULL && PyDescr_IsData(descr))
 			return f(descr, obj, (PyObject *)obj->ob_type);
--- 2058,2075 ----
 	PyMethodObject *im = (PyMethodObject *)obj;
 	PyTypeObject *tp = obj->ob_type;
! 	PyObject *descr = NULL, *res;
! 	descrgetfunc f = NULL;
 
! 	if (PyType_HasFeature(tp, Py_TPFLAGS_HAVE_CLASS)) {
! 		if (tp->tp_dict == NULL) {
! 			if (PyType_Ready(tp) < 0)
! 				return NULL;
! 		}
! 		descr = _PyType_Lookup(tp, name);
 	}
 
 	f = NULL;
 	if (descr != NULL) {
! 		f = TP_DESCR_GET(descr->ob_type);
 		if (f != NULL && PyDescr_IsData(descr))
 			return f(descr, obj, (PyObject *)obj->ob_type);

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