[Python-checkins] CVS: python/dist/src/Modules imgfile.c,1.29,1.30 dlmodule.c,2.20,2.21 bsddbmodule.c,1.33,1.34

Neal Norwitz nnorwitz@users.sourceforge.net
Sun, 31 Mar 2002 07:43:30 -0800


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

Modified Files:
	imgfile.c dlmodule.c bsddbmodule.c 
Log Message:
Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple
Please review for correctness.


Index: imgfile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/imgfile.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** imgfile.c	17 Jan 2002 23:15:58 -0000	1.29
--- imgfile.c	31 Mar 2002 15:43:28 -0000	1.30
***************
*** 76,80 ****
  	PyObject *rv;
      
! 	if (!PyArg_Parse(args, "i", &newval))
  		return NULL;
  	rv = PyInt_FromLong(top_to_bottom);
--- 76,80 ----
  	PyObject *rv;
      
! 	if (!PyArg_ParseTuple(args, "i:ttob", &newval))
  		return NULL;
  	rv = PyInt_FromLong(top_to_bottom);
***************
*** 96,100 ****
  	int yfirst, ylast, ystep;
  
! 	if ( !PyArg_Parse(args, "s", &fname) )
  		return NULL;
      
--- 96,100 ----
  	int yfirst, ylast, ystep;
  
! 	if ( !PyArg_ParseTuple(args, "s:read", &fname) )
  		return NULL;
      
***************
*** 251,258 ****
  	int xwtd, ywtd, xorig, yorig;
  	float xfac, yfac;
- 	int cnt;
  	IMAGE *image;
  	char *filter;
! 	double blur;
  	int extended;
  	int fmode = 0;
--- 251,257 ----
  	int xwtd, ywtd, xorig, yorig;
  	float xfac, yfac;
  	IMAGE *image;
  	char *filter;
! 	double blur = 1.0;
  	int extended;
  	int fmode = 0;
***************
*** 264,281 ****
  	** extended scale algorithm in stead of simple-minded pixel drop/dup.
  	*/
! 	extended = 0;
! 	cnt = PyTuple_Size(args);
! 	if ( cnt == 5 ) {
! 		extended = 1;
! 		if ( !PyArg_Parse(args, "(siisd)",
! 				  &fname, &xwtd, &ywtd, &filter, &blur) )
! 			return NULL;
! 	} else if ( cnt == 4 ) {
! 		extended = 1;
! 		if ( !PyArg_Parse(args, "(siis)",
! 				  &fname, &xwtd, &ywtd, &filter) )
! 			return NULL;
! 		blur = 1.0;
! 	} else if ( !PyArg_Parse(args, "(sii)", &fname, &xwtd, &ywtd) )
  		return NULL;
  
--- 263,269 ----
  	** extended scale algorithm in stead of simple-minded pixel drop/dup.
  	*/
! 	extended = PyTuple_Size(args) >= 4;
! 	if ( !PyArg_ParseTuple(args, "sii|sd",
! 			       &fname, &xwtd, &ywtd, &filter, &blur) )
  		return NULL;
  
***************
*** 392,396 ****
  	IMAGE *image;
      
! 	if ( !PyArg_Parse(args, "s", &fname) )
  		return NULL;
      
--- 380,384 ----
  	IMAGE *image;
      
! 	if ( !PyArg_ParseTuple(args, "s:getsizes", &fname) )
  		return NULL;
      
***************
*** 417,421 ****
  
  
! 	if ( !PyArg_Parse(args, "(ss#iii)",
  			  &fname, &cdatap, &len, &xsize, &ysize, &zsize) )
  		return NULL;
--- 405,409 ----
  
  
! 	if ( !PyArg_ParseTuple(args, "ss#iii:write",
  			  &fname, &cdatap, &len, &xsize, &ysize, &zsize) )
  		return NULL;
***************
*** 491,499 ****
  
  static PyMethodDef imgfile_methods[] = {
! 	{ "getsizes",	imgfile_getsizes, METH_OLDARGS },
! 	{ "read",	imgfile_read, METH_OLDARGS },
  	{ "readscaled",	imgfile_readscaled, METH_VARARGS},
! 	{ "write",	imgfile_write, METH_OLDARGS },
! 	{ "ttob",	imgfile_ttob, METH_OLDARGS },
  	{ NULL,		NULL } /* Sentinel */
  };
--- 479,487 ----
  
  static PyMethodDef imgfile_methods[] = {
! 	{ "getsizes",	imgfile_getsizes, METH_VARARGS },
! 	{ "read",	imgfile_read, METH_VARARGS },
  	{ "readscaled",	imgfile_readscaled, METH_VARARGS},
! 	{ "write",	imgfile_write, METH_VARARGS },
! 	{ "ttob",	imgfile_ttob, METH_VARARGS },
  	{ NULL,		NULL } /* Sentinel */
  };

Index: dlmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/dlmodule.c,v
retrieving revision 2.20
retrieving revision 2.21
diff -C2 -d -r2.20 -r2.21
*** dlmodule.c	17 Jan 2002 23:15:58 -0000	2.20
--- dlmodule.c	31 Mar 2002 15:43:28 -0000	2.21
***************
*** 40,47 ****
  
  static PyObject *
! dl_close(dlobject *xp, PyObject *args)
  {
- 	if (!PyArg_Parse(args, ""))
- 		return NULL;
  	if (xp->dl_handle != NULL) {
  		dlclose(xp->dl_handle);
--- 40,45 ----
  
  static PyObject *
! dl_close(dlobject *xp)
  {
  	if (xp->dl_handle != NULL) {
  		dlclose(xp->dl_handle);
***************
*** 57,62 ****
  	char *name;
  	PyUnivPtr *func;
! 	if (!PyArg_Parse(args, "s", &name))
  		return NULL;
  	func = dlsym(xp->dl_handle, name);
  	if (func == NULL) {
--- 55,65 ----
  	char *name;
  	PyUnivPtr *func;
! 	if (PyString_Check(args)) {
! 		name = PyString_AS_STRING(args);
! 	} else {
! 		PyErr_Format(PyExc_TypeError, "expected string, found %.200s",
! 			     args->ob_type->tp_name);
  		return NULL;
+ 	}
  	func = dlsym(xp->dl_handle, name);
  	if (func == NULL) {
***************
*** 122,127 ****
  static PyMethodDef dlobject_methods[] = {
  	{"call",	(PyCFunction)dl_call, METH_VARARGS},
! 	{"sym", 	(PyCFunction)dl_sym, METH_OLDARGS},
! 	{"close",	(PyCFunction)dl_close, METH_OLDARGS},
  	{NULL,  	NULL}			 /* Sentinel */
  };
--- 125,130 ----
  static PyMethodDef dlobject_methods[] = {
  	{"call",	(PyCFunction)dl_call, METH_VARARGS},
! 	{"sym", 	(PyCFunction)dl_sym, METH_O},
! 	{"close",	(PyCFunction)dl_close, METH_NOARGS},
  	{NULL,  	NULL}			 /* Sentinel */
  };
***************
*** 166,174 ****
  	}
  
! 	if (PyArg_Parse(args, "z", &name))
  		mode = RTLD_LAZY;
  	else {
  		PyErr_Clear();
! 		if (!PyArg_Parse(args, "(zi)", &name, &mode))
  			return NULL;
  #ifndef RTLD_NOW
--- 169,177 ----
  	}
  
! 	if (PyArg_ParseTuple(args, "z:open", &name))
  		mode = RTLD_LAZY;
  	else {
  		PyErr_Clear();
! 		if (!PyArg_ParseTuple(args, "zi:open", &name, &mode))
  			return NULL;
  #ifndef RTLD_NOW
***************
*** 188,192 ****
  
  static PyMethodDef dl_methods[] = {
! 	{"open",	dl_open, METH_OLDARGS},
  	{NULL,		NULL}		/* sentinel */
  };
--- 191,195 ----
  
  static PyMethodDef dl_methods[] = {
! 	{"open",	dl_open, METH_VARARGS},
  	{NULL,		NULL}		/* sentinel */
  };

Index: bsddbmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/bsddbmodule.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** bsddbmodule.c	25 Mar 2002 20:46:45 -0000	1.33
--- bsddbmodule.c	31 Mar 2002 15:43:28 -0000	1.34
***************
*** 471,477 ****
  
  	if (dp->di_type == DB_RECNO) {
! 		if (!PyArg_Parse(args, "i", &recno)) {
! 			PyErr_SetString(PyExc_TypeError,
! 					"key type must be integer");
  			return NULL;
  		}
--- 471,476 ----
  
  	if (dp->di_type == DB_RECNO) {
! 		if (!PyArg_ParseTuple(args, "i;key type must be integer",
! 				      &recno)) {
  			return NULL;
  		}
***************
*** 480,486 ****
  	}
  	else {
! 		if (!PyArg_Parse(args, "s#", &data, &size)) {
! 			PyErr_SetString(PyExc_TypeError,
! 					"key type must be string");
  			return NULL;
  		}
--- 479,484 ----
  	}
  	else {
! 		if (!PyArg_ParseTuple(args, "s#;key type must be string",
! 				      &data, &size)) {
  			return NULL;
  		}
***************
*** 512,518 ****
  
  	if (dp->di_type == DB_RECNO) {
! 		if (!PyArg_Parse(key, "i", &recno)) {
! 			PyErr_SetString(PyExc_TypeError,
! 					"key type must be integer");
  			return NULL;
  		}
--- 510,515 ----
  
  	if (dp->di_type == DB_RECNO) {
! 		if (!PyArg_ParseTuple(key, "i;key type must be integer",
! 				      &recno)) {
  			return NULL;
  		}
***************
*** 521,527 ****
  	}
  	else {
! 		if (!PyArg_Parse(key, "s#", &data, &size)) {
! 			PyErr_SetString(PyExc_TypeError,
! 					"key type must be string");
  			return NULL;
  		}
--- 518,523 ----
  	}
  	else {
! 		if (!PyArg_ParseTuple(key, "s#;key type must be string",
! 				      &data, &size)) {
  			return NULL;
  		}
***************
*** 645,650 ****
  	{"close",		(PyCFunction)bsddb_close, METH_NOARGS},
  	{"keys",		(PyCFunction)bsddb_keys, METH_NOARGS},
! 	{"has_key",		(PyCFunction)bsddb_has_key, METH_OLDARGS},
! 	{"set_location",	(PyCFunction)bsddb_set_location, METH_OLDARGS},
  	{"next",		(PyCFunction)bsddb_next, METH_NOARGS},
  	{"previous",	(PyCFunction)bsddb_previous, METH_NOARGS},
--- 641,646 ----
  	{"close",		(PyCFunction)bsddb_close, METH_NOARGS},
  	{"keys",		(PyCFunction)bsddb_keys, METH_NOARGS},
! 	{"has_key",		(PyCFunction)bsddb_has_key, METH_VARARGS},
! 	{"set_location",	(PyCFunction)bsddb_set_location, METH_VARARGS},
  	{"next",		(PyCFunction)bsddb_next, METH_NOARGS},
  	{"previous",	(PyCFunction)bsddb_previous, METH_NOARGS},