[Python-checkins] CVS: python/dist/src/Objects funcobject.c,2.50,2.50.4.1

Guido van Rossum gvanrossum@users.sourceforge.net
Sun, 17 Mar 2002 19:05:38 -0800


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

Modified Files:
      Tag: release22-maint
	funcobject.c 
Log Message:
Fix for SF bug 528132 (Armin Rigo): classmethod().__get__() segfault

The proper fix is not quite what was submitted; it's really better to
take the class of the object passed rather than calling PyMethod_New
with NULL pointer args, because that can then cause other core dumps
later.

I also added a testcase for the fix to classmethods() in test_descr.py.

I'll apply this to 2.3 too.



Index: funcobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v
retrieving revision 2.50
retrieving revision 2.50.4.1
diff -C2 -d -r2.50 -r2.50.4.1
*** funcobject.c	17 Dec 2001 11:39:56 -0000	2.50
--- funcobject.c	18 Mar 2002 03:05:35 -0000	2.50.4.1
***************
*** 475,478 ****
--- 475,480 ----
  		return NULL;
  	}
+ 	if (type == NULL)
+ 		type = (PyObject *)(obj->ob_type);
   	return PyMethod_New(cm->cm_callable,
  			    type, (PyObject *)(type->ob_type));