mirror of https://github.com/python/cpython.git
Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple
Please review for correctness.
This commit is contained in:
parent
ba3a16c6c3
commit
b82d34f91e
|
@ -470,18 +470,16 @@ bsddb_has_key(bsddbobject *dp, PyObject *args)
|
||||||
recno_t recno;
|
recno_t recno;
|
||||||
|
|
||||||
if (dp->di_type == DB_RECNO) {
|
if (dp->di_type == DB_RECNO) {
|
||||||
if (!PyArg_Parse(args, "i", &recno)) {
|
if (!PyArg_ParseTuple(args, "i;key type must be integer",
|
||||||
PyErr_SetString(PyExc_TypeError,
|
&recno)) {
|
||||||
"key type must be integer");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
krec.data = &recno;
|
krec.data = &recno;
|
||||||
krec.size = sizeof(recno);
|
krec.size = sizeof(recno);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!PyArg_Parse(args, "s#", &data, &size)) {
|
if (!PyArg_ParseTuple(args, "s#;key type must be string",
|
||||||
PyErr_SetString(PyExc_TypeError,
|
&data, &size)) {
|
||||||
"key type must be string");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
krec.data = data;
|
krec.data = data;
|
||||||
|
@ -511,18 +509,16 @@ bsddb_set_location(bsddbobject *dp, PyObject *key)
|
||||||
recno_t recno;
|
recno_t recno;
|
||||||
|
|
||||||
if (dp->di_type == DB_RECNO) {
|
if (dp->di_type == DB_RECNO) {
|
||||||
if (!PyArg_Parse(key, "i", &recno)) {
|
if (!PyArg_ParseTuple(key, "i;key type must be integer",
|
||||||
PyErr_SetString(PyExc_TypeError,
|
&recno)) {
|
||||||
"key type must be integer");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
krec.data = &recno;
|
krec.data = &recno;
|
||||||
krec.size = sizeof(recno);
|
krec.size = sizeof(recno);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!PyArg_Parse(key, "s#", &data, &size)) {
|
if (!PyArg_ParseTuple(key, "s#;key type must be string",
|
||||||
PyErr_SetString(PyExc_TypeError,
|
&data, &size)) {
|
||||||
"key type must be string");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
krec.data = data;
|
krec.data = data;
|
||||||
|
@ -644,8 +640,8 @@ bsddb_sync(bsddbobject *dp)
|
||||||
static PyMethodDef bsddb_methods[] = {
|
static PyMethodDef bsddb_methods[] = {
|
||||||
{"close", (PyCFunction)bsddb_close, METH_NOARGS},
|
{"close", (PyCFunction)bsddb_close, METH_NOARGS},
|
||||||
{"keys", (PyCFunction)bsddb_keys, METH_NOARGS},
|
{"keys", (PyCFunction)bsddb_keys, METH_NOARGS},
|
||||||
{"has_key", (PyCFunction)bsddb_has_key, METH_OLDARGS},
|
{"has_key", (PyCFunction)bsddb_has_key, METH_VARARGS},
|
||||||
{"set_location", (PyCFunction)bsddb_set_location, METH_OLDARGS},
|
{"set_location", (PyCFunction)bsddb_set_location, METH_VARARGS},
|
||||||
{"next", (PyCFunction)bsddb_next, METH_NOARGS},
|
{"next", (PyCFunction)bsddb_next, METH_NOARGS},
|
||||||
{"previous", (PyCFunction)bsddb_previous, METH_NOARGS},
|
{"previous", (PyCFunction)bsddb_previous, METH_NOARGS},
|
||||||
{"first", (PyCFunction)bsddb_first, METH_NOARGS},
|
{"first", (PyCFunction)bsddb_first, METH_NOARGS},
|
||||||
|
|
|
@ -39,10 +39,8 @@ dl_dealloc(dlobject *xp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
dl_close(dlobject *xp, PyObject *args)
|
dl_close(dlobject *xp)
|
||||||
{
|
{
|
||||||
if (!PyArg_Parse(args, ""))
|
|
||||||
return NULL;
|
|
||||||
if (xp->dl_handle != NULL) {
|
if (xp->dl_handle != NULL) {
|
||||||
dlclose(xp->dl_handle);
|
dlclose(xp->dl_handle);
|
||||||
xp->dl_handle = NULL;
|
xp->dl_handle = NULL;
|
||||||
|
@ -56,8 +54,13 @@ dl_sym(dlobject *xp, PyObject *args)
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
PyUnivPtr *func;
|
PyUnivPtr *func;
|
||||||
if (!PyArg_Parse(args, "s", &name))
|
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;
|
return NULL;
|
||||||
|
}
|
||||||
func = dlsym(xp->dl_handle, name);
|
func = dlsym(xp->dl_handle, name);
|
||||||
if (func == NULL) {
|
if (func == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
|
@ -121,8 +124,8 @@ dl_call(dlobject *xp, PyObject *args)
|
||||||
|
|
||||||
static PyMethodDef dlobject_methods[] = {
|
static PyMethodDef dlobject_methods[] = {
|
||||||
{"call", (PyCFunction)dl_call, METH_VARARGS},
|
{"call", (PyCFunction)dl_call, METH_VARARGS},
|
||||||
{"sym", (PyCFunction)dl_sym, METH_OLDARGS},
|
{"sym", (PyCFunction)dl_sym, METH_O},
|
||||||
{"close", (PyCFunction)dl_close, METH_OLDARGS},
|
{"close", (PyCFunction)dl_close, METH_NOARGS},
|
||||||
{NULL, NULL} /* Sentinel */
|
{NULL, NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -165,11 +168,11 @@ dl_open(PyObject *self, PyObject *args)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PyArg_Parse(args, "z", &name))
|
if (PyArg_ParseTuple(args, "z:open", &name))
|
||||||
mode = RTLD_LAZY;
|
mode = RTLD_LAZY;
|
||||||
else {
|
else {
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
if (!PyArg_Parse(args, "(zi)", &name, &mode))
|
if (!PyArg_ParseTuple(args, "zi:open", &name, &mode))
|
||||||
return NULL;
|
return NULL;
|
||||||
#ifndef RTLD_NOW
|
#ifndef RTLD_NOW
|
||||||
if (mode != RTLD_LAZY) {
|
if (mode != RTLD_LAZY) {
|
||||||
|
@ -187,7 +190,7 @@ dl_open(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyMethodDef dl_methods[] = {
|
static PyMethodDef dl_methods[] = {
|
||||||
{"open", dl_open, METH_OLDARGS},
|
{"open", dl_open, METH_VARARGS},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ imgfile_ttob(PyObject *self, PyObject *args)
|
||||||
int newval;
|
int newval;
|
||||||
PyObject *rv;
|
PyObject *rv;
|
||||||
|
|
||||||
if (!PyArg_Parse(args, "i", &newval))
|
if (!PyArg_ParseTuple(args, "i:ttob", &newval))
|
||||||
return NULL;
|
return NULL;
|
||||||
rv = PyInt_FromLong(top_to_bottom);
|
rv = PyInt_FromLong(top_to_bottom);
|
||||||
top_to_bottom = newval;
|
top_to_bottom = newval;
|
||||||
|
@ -95,7 +95,7 @@ imgfile_read(PyObject *self, PyObject *args)
|
||||||
IMAGE *image;
|
IMAGE *image;
|
||||||
int yfirst, ylast, ystep;
|
int yfirst, ylast, ystep;
|
||||||
|
|
||||||
if ( !PyArg_Parse(args, "s", &fname) )
|
if ( !PyArg_ParseTuple(args, "s:read", &fname) )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if ( (image = imgfile_open(fname)) == NULL )
|
if ( (image = imgfile_open(fname)) == NULL )
|
||||||
|
@ -250,10 +250,9 @@ imgfile_readscaled(PyObject *self, PyObject *args)
|
||||||
int x, y;
|
int x, y;
|
||||||
int xwtd, ywtd, xorig, yorig;
|
int xwtd, ywtd, xorig, yorig;
|
||||||
float xfac, yfac;
|
float xfac, yfac;
|
||||||
int cnt;
|
|
||||||
IMAGE *image;
|
IMAGE *image;
|
||||||
char *filter;
|
char *filter;
|
||||||
double blur;
|
double blur = 1.0;
|
||||||
int extended;
|
int extended;
|
||||||
int fmode = 0;
|
int fmode = 0;
|
||||||
int yfirst, ylast, ystep;
|
int yfirst, ylast, ystep;
|
||||||
|
@ -263,20 +262,9 @@ imgfile_readscaled(PyObject *self, PyObject *args)
|
||||||
** (filter name and blur factor). Also, 4 or 5 arguments indicates
|
** (filter name and blur factor). Also, 4 or 5 arguments indicates
|
||||||
** extended scale algorithm in stead of simple-minded pixel drop/dup.
|
** extended scale algorithm in stead of simple-minded pixel drop/dup.
|
||||||
*/
|
*/
|
||||||
extended = 0;
|
extended = PyTuple_Size(args) >= 4;
|
||||||
cnt = PyTuple_Size(args);
|
if ( !PyArg_ParseTuple(args, "sii|sd",
|
||||||
if ( cnt == 5 ) {
|
&fname, &xwtd, &ywtd, &filter, &blur) )
|
||||||
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;
|
return NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -391,7 +379,7 @@ imgfile_getsizes(PyObject *self, PyObject *args)
|
||||||
PyObject *rv;
|
PyObject *rv;
|
||||||
IMAGE *image;
|
IMAGE *image;
|
||||||
|
|
||||||
if ( !PyArg_Parse(args, "s", &fname) )
|
if ( !PyArg_ParseTuple(args, "s:getsizes", &fname) )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if ( (image = imgfile_open(fname)) == NULL )
|
if ( (image = imgfile_open(fname)) == NULL )
|
||||||
|
@ -416,7 +404,7 @@ imgfile_write(PyObject *self, PyObject *args)
|
||||||
int yfirst, ylast, ystep;
|
int yfirst, ylast, ystep;
|
||||||
|
|
||||||
|
|
||||||
if ( !PyArg_Parse(args, "(ss#iii)",
|
if ( !PyArg_ParseTuple(args, "ss#iii:write",
|
||||||
&fname, &cdatap, &len, &xsize, &ysize, &zsize) )
|
&fname, &cdatap, &len, &xsize, &ysize, &zsize) )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -490,11 +478,11 @@ imgfile_write(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
|
|
||||||
static PyMethodDef imgfile_methods[] = {
|
static PyMethodDef imgfile_methods[] = {
|
||||||
{ "getsizes", imgfile_getsizes, METH_OLDARGS },
|
{ "getsizes", imgfile_getsizes, METH_VARARGS },
|
||||||
{ "read", imgfile_read, METH_OLDARGS },
|
{ "read", imgfile_read, METH_VARARGS },
|
||||||
{ "readscaled", imgfile_readscaled, METH_VARARGS},
|
{ "readscaled", imgfile_readscaled, METH_VARARGS},
|
||||||
{ "write", imgfile_write, METH_OLDARGS },
|
{ "write", imgfile_write, METH_VARARGS },
|
||||||
{ "ttob", imgfile_ttob, METH_OLDARGS },
|
{ "ttob", imgfile_ttob, METH_VARARGS },
|
||||||
{ NULL, NULL } /* Sentinel */
|
{ NULL, NULL } /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue