[Python-checkins] CVS: python/dist/src/Modules arraymodule.c,2.39,2.40 posixmodule.c,2.134,2.135 structmodule.c,2.30,2.31

Fred L. Drake python-dev@python.org
Wed, 31 May 2000 19:02:54 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv29510

Modified Files:
	arraymodule.c posixmodule.c structmodule.c 
Log Message:
Michael Hudson <mwh21@cam.ac.uk>:
Removed PyErr_BadArgument() calls and replaced them with more useful
error messages.


Index: arraymodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/arraymodule.c,v
retrieving revision 2.39
retrieving revision 2.40
diff -C2 -r2.39 -r2.40
*** arraymodule.c	2000/05/03 23:44:31	2.39
--- arraymodule.c	2000/06/01 02:02:46	2.40
***************
*** 541,545 ****
  	arrayobject *np;
  	if (!is_arrayobject(bb)) {
! 		PyErr_BadArgument();
  		return NULL;
  	}
--- 541,547 ----
  	arrayobject *np;
  	if (!is_arrayobject(bb)) {
! 		PyErr_Format(PyExc_TypeError,
! 		     "can only append array (not \"%.200s\") to array",
! 			     bb->ob_type->tp_name);
  		return NULL;
  	}
***************
*** 614,618 ****
  	}
  	else {
! 		PyErr_BadArgument();
  		return -1;
  	}
--- 616,622 ----
  	}
  	else {
! 		PyErr_Format(PyExc_TypeError,
! 	     "can only assign array (not \"%.200s\") to array slice",
! 			     v->ob_type->tp_name);
  		return -1;
  	}
***************
*** 822,826 ****
  
  	if (args != NULL) {
! 		PyErr_BadArgument();
  		return NULL;
  	}
--- 826,831 ----
  
  	if (args != NULL) {
! 		PyErr_SetString(PyExc_TypeError,
! 		     "<array>.reverse requires exactly 0 arguments");
  		return NULL;
  	}

Index: posixmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v
retrieving revision 2.134
retrieving revision 2.135
diff -C2 -r2.134 -r2.135
*** posixmodule.c	2000/05/03 02:44:55	2.134
--- posixmodule.c	2000/06/01 02:02:46	2.135
***************
*** 1563,1568 ****
  	}
  	else {
!  badarg:
! 		PyErr_BadArgument();
  		return NULL;
  	}
--- 1563,1567 ----
  	}
  	else {
! 		PyErr_SetString(PyExc_TypeError, "argv must be tuple or list");
  		return NULL;
  	}
***************
*** 1574,1578 ****
  		if (!PyArg_Parse((*getitem)(argv, i), "s", &argvlist[i])) {
  			PyMem_DEL(argvlist);
! 			goto badarg;
  		}
  	}
--- 1573,1579 ----
  		if (!PyArg_Parse((*getitem)(argv, i), "s", &argvlist[i])) {
  			PyMem_DEL(argvlist);
! 			PyErr_SetString(PyExc_TypeError, 
! 					"all arguments must be strings");
! 			return NULL;
  		}
  	}

Index: structmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/structmodule.c,v
retrieving revision 2.30
retrieving revision 2.31
diff -C2 -r2.30 -r2.31
*** structmodule.c	2000/02/29 13:59:24	2.30
--- structmodule.c	2000/06/01 02:02:46	2.31
***************
*** 1129,1133 ****
  	    (n = PyTuple_Size(args)) < 1)
          {
! 		PyErr_BadArgument();
  		return NULL;
  	}
--- 1129,1134 ----
  	    (n = PyTuple_Size(args)) < 1)
          {
! 		PyErr_SetString(PyExc_TypeError, 
! 			"struct.pack requires at least one argument");
  		return NULL;
  	}