[Python-checkins] python/dist/src/Objects typeobject.c,2.205,2.206

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Tue, 11 Feb 2003 08:25:48 -0800


Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1:/tmp/cvs-serv3318

Modified Files:
	typeobject.c 
Log Message:
Add basic arg sanity checking to wrap_descr_get().  This is called
when Python code calls a descriptor's __get__ method.  It should
translate None to NULL in both argument positions, and insist that at
least one of the argument positions is not NULL after this
transformation.


Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.205
retrieving revision 2.206
diff -C2 -d -r2.205 -r2.206
*** typeobject.c	10 Feb 2003 21:31:27 -0000	2.205
--- typeobject.c	11 Feb 2003 16:25:43 -0000	2.206
***************
*** 3434,3437 ****
--- 3434,3446 ----
  	if (!PyArg_ParseTuple(args, "O|O", &obj, &type))
  		return NULL;
+ 	if (obj == Py_None)
+ 		obj = NULL;
+ 	if (type == Py_None)
+ 		type = NULL;
+ 	if (type == NULL &&obj == NULL) {
+ 		PyErr_SetString(PyExc_TypeError,
+ 				"__get__(None, None) is invalid");
+ 		return NULL;
+ 	}
  	return (*func)(self, obj, type);
  }