[Python-checkins] CVS: python/dist/src/Objects descrobject.c,1.1.2.9,1.1.2.10

Guido van Rossum gvanrossum@users.sourceforge.net
Fri, 29 Jun 2001 07:19:34 -0700


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

Modified Files:
      Tag: descr-branch
	descrobject.c 
Log Message:
descr_call(): improve two error messages.


Index: descrobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/Attic/descrobject.c,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -C2 -r1.1.2.9 -r1.1.2.10
*** descrobject.c	2001/06/06 14:27:54	1.1.2.9
--- descrobject.c	2001/06/29 14:19:30	1.1.2.10
***************
*** 204,217 ****
  	if (argc < 1) {
  		PyErr_SetString(PyExc_TypeError,
! 				"descriptor call needs 'self' argument");
  		return NULL;
  	}
  	self = PyTuple_GET_ITEM(args, 0);
  	if (!PyObject_IsInstance(self, (PyObject *)(descr->d_type))) {
  		PyErr_Format(PyExc_TypeError,
! 			     "descriptor call 'self' is type '%.100s', "
! 			     "expected type '%.100s'",
! 			     self->ob_type->tp_name,
! 			     descr->d_type->tp_name);
  		return NULL;
  	}
--- 204,222 ----
  	if (argc < 1) {
  		PyErr_SetString(PyExc_TypeError,
! 				"descriptor call needs a self argument");
  		return NULL;
  	}
  	self = PyTuple_GET_ITEM(args, 0);
  	if (!PyObject_IsInstance(self, (PyObject *)(descr->d_type))) {
+ 		char *name = descr_name(descr);
+ 		if (name == NULL)
+ 			name = "?";
  		PyErr_Format(PyExc_TypeError,
! 			     "descriptor '%.100s' "
! 			     "requires a '%.100s', "
! 			     "received a '%.100s'",
! 			     name,
! 			     descr->d_type->tp_name,
! 			     self->ob_type->tp_name);
  		return NULL;
  	}