[Python-checkins] CVS: python/dist/src/Python ceval.c,2.236,2.237

Guido van Rossum gvanrossum@users.sourceforge.net
Fri, 13 Apr 2001 08:42:42 -0700


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

Modified Files:
	ceval.c 
Log Message:
Patch by Ping (SF bug 415879, Exception.__init__() causes segfault):

   Calling an unbound method on a C extension class without providing
   an instance can yield a segfault.  Try "Exception.__init__()" or
   "ValueError.__init__()".

   This is a simple fix. The error-reporting bits in call_method
   mistakenly treat the misleadingly-named variable "func" as a
   function, when in fact it is a method.

   If we let get_func_name take care of the work, all is fine.


Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.236
retrieving revision 2.237
diff -C2 -r2.236 -r2.237
*** ceval.c	2001/04/11 13:52:29	2.236
--- ceval.c	2001/04/13 15:42:40	2.237
***************
*** 2884,2893 ****
  		}
  		if (!ok) {
! 			PyObject* fn = ((PyFunctionObject*) func)->func_name;
  			PyErr_Format(PyExc_TypeError,
  				     "unbound method %s%smust be "
  				     "called with instance as first argument",
! 				     fn ? PyString_AsString(fn) : "",
! 				     fn ? "() " : "");
  			return NULL;
  		}
--- 2884,2892 ----
  		}
  		if (!ok) {
! 			char* fn = get_func_name(func);
  			PyErr_Format(PyExc_TypeError,
  				     "unbound method %s%smust be "
  				     "called with instance as first argument",
! 				     fn ? fn : "", fn ? "() " : "");
  			return NULL;
  		}