[Python-checkins] python/dist/src/Objects typeobject.c,2.126.4.37,2.126.4.38

bwarsaw@users.sourceforge.net bwarsaw@users.sourceforge.net
Thu, 29 May 2003 08:13:21 -0700


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

Modified Files:
      Tag: release22-maint
	typeobject.c 
Log Message:
Backport patch 2.206:

    ----------------------------
    revision 2.206
    date: 2003/02/11 16:25:43;  author: gvanrossum;  state: Exp;  lines: +9 -0
    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.
    ----------------------------

which fixes SF bug # 736892, forcing function to act like an unbound
method dumps core.


Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.126.4.37
retrieving revision 2.126.4.38
diff -C2 -d -r2.126.4.37 -r2.126.4.38
*** typeobject.c	29 May 2003 14:28:22 -0000	2.126.4.37
--- typeobject.c	29 May 2003 15:13:18 -0000	2.126.4.38
***************
*** 2750,2753 ****
--- 2750,2762 ----
  	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);
  }