summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2002-03-31 15:27:00 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2002-03-31 15:27:00 (GMT)
commitba3a16c6c3d3da0903873e9464dbc540eaeda1f7 (patch)
tree6094d419dcf56dfdb9bdb50da0a15d0c0160573a /Modules
parent50905b557b2a46d4db432b7a9e61fe32afa557e3 (diff)
downloadcpython-ba3a16c6c3d3da0903873e9464dbc540eaeda1f7.zip
cpython-ba3a16c6c3d3da0903873e9464dbc540eaeda1f7.tar.gz
cpython-ba3a16c6c3d3da0903873e9464dbc540eaeda1f7.tar.bz2
Remove METH_OLDARGS:
Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple Convert METH_OLDARGS -> METH_NOARGS: remove args parameter Please review. All tests pass, but some modules don't have tests. I spot checked various functions to try to make sure nothing broke.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/cryptmodule.c4
-rw-r--r--Modules/md5module.c4
-rw-r--r--Modules/mpzmodule.c67
-rw-r--r--Modules/nismodule.c14
-rw-r--r--Modules/pwdmodule.c8
-rw-r--r--Modules/regexmodule.c18
-rw-r--r--Modules/rgbimgmodule.c18
-rw-r--r--Modules/rotormodule.c18
-rw-r--r--Modules/signalmodule.c14
-rw-r--r--Modules/sunaudiodev.c65
-rw-r--r--Modules/threadmodule.c19
11 files changed, 85 insertions, 164 deletions
diff --git a/Modules/cryptmodule.c b/Modules/cryptmodule.c
index 1e66039..b1c8f5e 100644
--- a/Modules/cryptmodule.c
+++ b/Modules/cryptmodule.c
@@ -14,7 +14,7 @@ static PyObject *crypt_crypt(PyObject *self, PyObject *args)
char *word, *salt;
extern char * crypt(const char *, const char *);
- if (!PyArg_Parse(args, "(ss)", &word, &salt)) {
+ if (!PyArg_ParseTuple(args, "ss:crypt", &word, &salt)) {
return NULL;
}
return PyString_FromString( crypt( word, salt ) );
@@ -31,7 +31,7 @@ the same alphabet as the salt.";
static PyMethodDef crypt_methods[] = {
- {"crypt", crypt_crypt, METH_OLDARGS, crypt_crypt__doc__},
+ {"crypt", crypt_crypt, METH_VARARGS, crypt_crypt__doc__},
{NULL, NULL} /* sentinel */
};
diff --git a/Modules/md5module.c b/Modules/md5module.c
index fb904f4..a6068ff 100644
--- a/Modules/md5module.c
+++ b/Modules/md5module.c
@@ -52,7 +52,7 @@ md5_update(md5object *self, PyObject *args)
unsigned char *cp;
int len;
- if (!PyArg_Parse(args, "s#", &cp, &len))
+ if (!PyArg_ParseTuple(args, "s#:update", &cp, &len))
return NULL;
MD5Update(&self->md5, cp, len);
@@ -142,7 +142,7 @@ Return a copy (``clone'') of the md5 object.";
static PyMethodDef md5_methods[] = {
- {"update", (PyCFunction)md5_update, METH_OLDARGS, update_doc},
+ {"update", (PyCFunction)md5_update, METH_VARARGS, update_doc},
{"digest", (PyCFunction)md5_digest, METH_NOARGS, digest_doc},
{"hexdigest", (PyCFunction)md5_hexdigest, METH_NOARGS, hexdigest_doc},
{"copy", (PyCFunction)md5_copy, METH_NOARGS, copy_doc},
diff --git a/Modules/mpzmodule.c b/Modules/mpzmodule.c
index e2d34b6..84685ed 100644
--- a/Modules/mpzmodule.c
+++ b/Modules/mpzmodule.c
@@ -1242,23 +1242,12 @@ MPZ_divm(PyObject *self, PyObject *args)
} /* MPZ_divm() */
-/* MPZ methods-as-attributes */
-#ifdef MPZ_CONVERSIONS_AS_METHODS
-static PyObject *
-mpz_int(mpzobject *self, PyObject *args)
-#else /* def MPZ_CONVERSIONS_AS_METHODS */
static PyObject *
mpz_int(mpzobject *self)
-#endif /* def MPZ_CONVERSIONS_AS_METHODS else */
{
long sli;
-#ifdef MPZ_CONVERSIONS_AS_METHODS
- if (!PyArg_NoArgs(args))
- return NULL;
-#endif /* def MPZ_CONVERSIONS_AS_METHODS */
-
if (mpz_size(&self->mpz) > 1
|| (sli = (long)mpz_get_ui(&self->mpz)) < (long)0 ) {
PyErr_SetString(PyExc_ValueError,
@@ -1273,11 +1262,7 @@ mpz_int(mpzobject *self)
} /* mpz_int() */
static PyObject *
-#ifdef MPZ_CONVERSIONS_AS_METHODS
-mpz_long(mpzobject *self, PyObject *args)
-#else /* def MPZ_CONVERSIONS_AS_METHODS */
mpz_long(mpzobject *self)
-#endif /* def MPZ_CONVERSIONS_AS_METHODS else */
{
int i, isnegative;
unsigned long int uli;
@@ -1287,11 +1272,6 @@ mpz_long(mpzobject *self)
MP_INT mpzscratch;
-#ifdef MPZ_CONVERSIONS_AS_METHODS
- if (!PyArg_NoArgs(args))
- return NULL;
-#endif /* def MPZ_CONVERSIONS_AS_METHODS */
-
/* determine length of python-long to be allocated */
if ((longobjp = _PyLong_New(i = (int)
((mpz_size(&self->mpz) * BITS_PER_MP_LIMB
@@ -1352,13 +1332,8 @@ mpz_long(mpzobject *self)
/* I would have avoided pow() anyways, so ... */
static const double multiplier = 256.0 * 256.0 * 256.0 * 256.0;
-#ifdef MPZ_CONVERSIONS_AS_METHODS
-static PyObject *
-mpz_float(mpzobject *self, PyObject *args)
-#else /* def MPZ_CONVERSIONS_AS_METHODS */
static PyObject *
mpz_float(mpzobject *self)
-#endif /* def MPZ_CONVERSIONS_AS_METHODS else */
{
int i, isnegative;
double x;
@@ -1366,11 +1341,6 @@ mpz_float(mpzobject *self)
MP_INT mpzscratch;
-#ifdef MPZ_CONVERSIONS_AS_METHODS
- if (!PyArg_NoArgs(args))
- return NULL;
-#endif /* def MPZ_CONVERSIONS_AS_METHODS */
-
i = (int)mpz_size(&self->mpz);
/* determine sign, and copy abs(self) to scratch var */
@@ -1406,40 +1376,20 @@ mpz_float(mpzobject *self)
} /* mpz_float() */
-#ifdef MPZ_CONVERSIONS_AS_METHODS
-static PyObject *
-mpz_hex(mpzobject *self, PyObject *args)
-#else /* def MPZ_CONVERSIONS_AS_METHODS */
static PyObject *
mpz_hex(mpzobject *self)
-#endif /* def MPZ_CONVERSIONS_AS_METHODS else */
{
-#ifdef MPZ_CONVERSIONS_AS_METHODS
- if (!PyArg_NoArgs(args))
- return NULL;
-#endif /* def MPZ_CONVERSIONS_AS_METHODS */
-
return mpz_format((PyObject *)self, 16, (unsigned char)1);
} /* mpz_hex() */
-#ifdef MPZ_CONVERSIONS_AS_METHODS
-static PyObject *
-mpz_oct(mpzobject *self, PyObject *args)
-#else /* def MPZ_CONVERSIONS_AS_METHODS */
static PyObject *
mpz_oct(mpzobject *self)
-#endif /* def MPZ_CONVERSIONS_AS_METHODS else */
{
-#ifdef MPZ_CONVERSIONS_AS_METHODS
- if (!PyArg_NoArgs(args))
- return NULL;
-#endif /* def MPZ_CONVERSIONS_AS_METHODS */
-
return mpz_format((PyObject *)self, 8, (unsigned char)1);
} /* mpz_oct() */
static PyObject *
-mpz_binary(mpzobject *self, PyObject *args)
+mpz_binary(mpzobject *self)
{
int size;
PyStringObject *strobjp;
@@ -1447,9 +1397,6 @@ mpz_binary(mpzobject *self, PyObject *args)
MP_INT mp;
unsigned long ldigit;
- if (!PyArg_NoArgs(args))
- return NULL;
-
if (mpz_cmp_ui(&self->mpz, (unsigned long int)0) < 0) {
PyErr_SetString(PyExc_ValueError,
"mpz.binary() arg must be >= 0");
@@ -1493,13 +1440,13 @@ mpz_binary(mpzobject *self, PyObject *args)
static PyMethodDef mpz_methods[] = {
#ifdef MPZ_CONVERSIONS_AS_METHODS
- {"int", mpz_int},
- {"long", mpz_long},
- {"float", mpz_float},
- {"hex", mpz_hex},
- {"oct", mpz_oct},
+ {"int", mpz_int, METH_NOARGS},
+ {"long", mpz_long, METH_NOARGS},
+ {"float", mpz_float, METH_NOARGS},
+ {"hex", mpz_hex, METH_NOARGS},
+ {"oct", mpz_oct, METH_NOARGS},
#endif /* def MPZ_CONVERSIONS_AS_METHODS */
- {"binary", (PyCFunction)mpz_binary},
+ {"binary", (PyCFunction)mpz_binary, METH_NOARGS},
{NULL, NULL} /* sentinel */
};
diff --git a/Modules/nismodule.c b/Modules/nismodule.c
index f8a9246..f66e9a1 100644
--- a/Modules/nismodule.c
+++ b/Modules/nismodule.c
@@ -120,7 +120,7 @@ nis_match (PyObject *self, PyObject *args)
PyObject *res;
int fix;
- if (!PyArg_Parse(args, "(t#s)", &key, &keylen, &map))
+ if (!PyArg_ParseTuple(args, "t#s:match", &key, &keylen, &map))
return NULL;
if ((err = yp_get_default_domain(&domain)) != 0)
return nis_error(err);
@@ -149,7 +149,7 @@ nis_cat (PyObject *self, PyObject *args)
PyObject *dict;
int err;
- if (!PyArg_Parse(args, "s", &map))
+ if (!PyArg_ParseTuple(args, "s:cat", &map))
return NULL;
if ((err = yp_get_default_domain(&domain)) != 0)
return nis_error(err);
@@ -338,13 +338,11 @@ nis_maplist (void)
}
static PyObject *
-nis_maps (PyObject *self, PyObject *args)
+nis_maps (PyObject *self)
{
nismaplist *maps;
PyObject *list;
- if (!PyArg_NoArgs(args))
- return NULL;
if ((maps = nis_maplist ()) == NULL)
return NULL;
if ((list = PyList_New(0)) == NULL)
@@ -364,9 +362,9 @@ nis_maps (PyObject *self, PyObject *args)
}
static PyMethodDef nis_methods[] = {
- {"match", nis_match, METH_OLDARGS},
- {"cat", nis_cat, METH_OLDARGS},
- {"maps", nis_maps, METH_OLDARGS},
+ {"match", nis_match, METH_VARARGS},
+ {"cat", nis_cat, METH_VARARGS},
+ {"maps", (PyCFunction)nis_maps, METH_NOARGS},
{NULL, NULL} /* Sentinel */
};
diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c
index 08c86d5..9656bba 100644
--- a/Modules/pwdmodule.c
+++ b/Modules/pwdmodule.c
@@ -84,7 +84,7 @@ pwd_getpwuid(PyObject *self, PyObject *args)
{
int uid;
struct passwd *p;
- if (!PyArg_Parse(args, "i", &uid))
+ if (!PyArg_ParseTuple(args, "i:getpwuid", &uid))
return NULL;
if ((p = getpwuid(uid)) == NULL) {
PyErr_SetString(PyExc_KeyError, "getpwuid(): uid not found");
@@ -103,7 +103,7 @@ pwd_getpwnam(PyObject *self, PyObject *args)
{
char *name;
struct passwd *p;
- if (!PyArg_Parse(args, "s", &name))
+ if (!PyArg_ParseTuple(args, "s:getpwnam", &name))
return NULL;
if ((p = getpwnam(name)) == NULL) {
PyErr_SetString(PyExc_KeyError, "getpwnam(): name not found");
@@ -146,8 +146,8 @@ pwd_getpwall(PyObject *self)
#endif
static PyMethodDef pwd_methods[] = {
- {"getpwuid", pwd_getpwuid, METH_OLDARGS, pwd_getpwuid__doc__},
- {"getpwnam", pwd_getpwnam, METH_OLDARGS, pwd_getpwnam__doc__},
+ {"getpwuid", pwd_getpwuid, METH_VARARGS, pwd_getpwuid__doc__},
+ {"getpwnam", pwd_getpwnam, METH_VARARGS, pwd_getpwnam__doc__},
#ifdef HAVE_GETPWENT
{"getpwall", (PyCFunction)pwd_getpwall,
METH_NOARGS, pwd_getpwall__doc__},
diff --git a/Modules/regexmodule.c b/Modules/regexmodule.c
index e65258d..d449604 100644
--- a/Modules/regexmodule.c
+++ b/Modules/regexmodule.c
@@ -583,7 +583,7 @@ regex_match(PyObject *self, PyObject *args)
PyObject *pat, *string;
PyObject *tuple, *v;
- if (!PyArg_Parse(args, "(SS)", &pat, &string))
+ if (!PyArg_ParseTuple(args, "SS:match", &pat, &string))
return NULL;
if (update_cache(pat) < 0)
return NULL;
@@ -601,7 +601,7 @@ regex_search(PyObject *self, PyObject *args)
PyObject *pat, *string;
PyObject *tuple, *v;
- if (!PyArg_Parse(args, "(SS)", &pat, &string))
+ if (!PyArg_ParseTuple(args, "SS:search", &pat, &string))
return NULL;
if (update_cache(pat) < 0)
return NULL;
@@ -617,7 +617,7 @@ static PyObject *
regex_set_syntax(PyObject *self, PyObject *args)
{
int syntax;
- if (!PyArg_Parse(args, "i", &syntax))
+ if (!PyArg_ParseTuple(args, "i:set_syntax", &syntax))
return NULL;
syntax = re_set_syntax(syntax);
/* wipe the global pattern cache */
@@ -629,10 +629,8 @@ regex_set_syntax(PyObject *self, PyObject *args)
}
static PyObject *
-regex_get_syntax(PyObject *self, PyObject *args)
+regex_get_syntax(PyObject *self)
{
- if (!PyArg_Parse(args, ""))
- return NULL;
return PyInt_FromLong((long)re_syntax);
}
@@ -640,10 +638,10 @@ regex_get_syntax(PyObject *self, PyObject *args)
static struct PyMethodDef regex_global_methods[] = {
{"compile", regex_compile, METH_VARARGS},
{"symcomp", regex_symcomp, METH_VARARGS},
- {"match", regex_match, METH_OLDARGS},
- {"search", regex_search, METH_OLDARGS},
- {"set_syntax", regex_set_syntax, METH_OLDARGS},
- {"get_syntax", regex_get_syntax, METH_OLDARGS},
+ {"match", regex_match, METH_VARARGS},
+ {"search", regex_search, METH_VARARGS},
+ {"set_syntax", regex_set_syntax, METH_VARARGS},
+ {"get_syntax", (PyCFunction)regex_get_syntax, METH_NOARGS},
{NULL, NULL} /* sentinel */
};
diff --git a/Modules/rgbimgmodule.c b/Modules/rgbimgmodule.c
index 828577f..596ea4f 100644
--- a/Modules/rgbimgmodule.c
+++ b/Modules/rgbimgmodule.c
@@ -236,7 +236,7 @@ sizeofimage(PyObject *self, PyObject *args)
IMAGE image;
FILE *inf;
- if (!PyArg_Parse(args, "s", &name))
+ if (!PyArg_ParseTuple(args, "s:sizeofimage", &name))
return NULL;
inf = fopen(name, "rb");
@@ -275,7 +275,7 @@ longimagedata(PyObject *self, PyObject *args)
int rlebuflen;
PyObject *rv = NULL;
- if (!PyArg_Parse(args, "s", &name))
+ if (!PyArg_ParseTuple(args, "s:longimagedata", &name))
return NULL;
inf = fopen(name,"rb");
@@ -570,8 +570,8 @@ longstoimage(PyObject *self, PyObject *args)
int rlebuflen, goodwrite;
PyObject *retval = NULL;
- if (!PyArg_Parse(args, "(s#iiis)", &lptr, &len, &xsize, &ysize, &zsize,
- &name))
+ if (!PyArg_ParseTuple(args, "s#iiis:longstoimage", &lptr, &len,
+ &xsize, &ysize, &zsize, &name))
return NULL;
goodwrite = 1;
@@ -734,7 +734,7 @@ ttob(PyObject *self, PyObject *args)
{
int order, oldorder;
- if (!PyArg_Parse(args, "i", &order))
+ if (!PyArg_ParseTuple(args, "i:ttob", &order))
return NULL;
oldorder = reverse_order;
reverse_order = order;
@@ -743,10 +743,10 @@ ttob(PyObject *self, PyObject *args)
static PyMethodDef
rgbimg_methods[] = {
- {"sizeofimage", sizeofimage, METH_OLDARGS},
- {"longimagedata", longimagedata, METH_OLDARGS},
- {"longstoimage", longstoimage, METH_OLDARGS},
- {"ttob", ttob, METH_OLDARGS},
+ {"sizeofimage", sizeofimage, METH_VARARGS},
+ {"longimagedata", longimagedata, METH_VARARGS},
+ {"longstoimage", longstoimage, METH_VARARGS},
+ {"ttob", ttob, METH_VARARGS},
{NULL, NULL} /* sentinel */
};
diff --git a/Modules/rotormodule.c b/Modules/rotormodule.c
index 23ded46..ea91af0 100644
--- a/Modules/rotormodule.c
+++ b/Modules/rotormodule.c
@@ -463,7 +463,7 @@ rotorobj_encrypt(Rotorobj *self, PyObject *args)
PyObject *rtn = NULL;
char *tmp;
- if (!PyArg_Parse(args, "s#", &string, &len))
+ if (!PyArg_ParseTuple(args, "s#:encrypt", &string, &len))
return NULL;
if (!(tmp = PyMem_NEW(char, len+5))) {
PyErr_NoMemory();
@@ -485,7 +485,7 @@ rotorobj_encrypt_more(Rotorobj *self, PyObject *args)
PyObject *rtn = NULL;
char *tmp;
- if (!PyArg_Parse(args, "s#", &string, &len))
+ if (!PyArg_ParseTuple(args, "s#:encrypt_more", &string, &len))
return NULL;
if (!(tmp = PyMem_NEW(char, len+5))) {
PyErr_NoMemory();
@@ -507,7 +507,7 @@ rotorobj_decrypt(Rotorobj *self, PyObject *args)
PyObject *rtn = NULL;
char *tmp;
- if (!PyArg_Parse(args, "s#", &string, &len))
+ if (!PyArg_ParseTuple(args, "s#:decrypt", &string, &len))
return NULL;
if (!(tmp = PyMem_NEW(char, len+5))) {
PyErr_NoMemory();
@@ -529,7 +529,7 @@ rotorobj_decrypt_more(Rotorobj *self, PyObject *args)
PyObject *rtn = NULL;
char *tmp;
- if (!PyArg_Parse(args, "s#", &string, &len))
+ if (!PyArg_ParseTuple(args, "s#:decrypt_more", &string, &len))
return NULL;
if (!(tmp = PyMem_NEW(char, len+5))) {
PyErr_NoMemory();
@@ -558,10 +558,10 @@ rotorobj_setkey(Rotorobj *self, PyObject *args)
static struct PyMethodDef
rotorobj_methods[] = {
- {"encrypt", (PyCFunction)rotorobj_encrypt, METH_OLDARGS},
- {"encryptmore", (PyCFunction)rotorobj_encrypt_more, METH_OLDARGS},
- {"decrypt", (PyCFunction)rotorobj_decrypt, METH_OLDARGS},
- {"decryptmore", (PyCFunction)rotorobj_decrypt_more, METH_OLDARGS},
+ {"encrypt", (PyCFunction)rotorobj_encrypt, METH_VARARGS},
+ {"encryptmore", (PyCFunction)rotorobj_encrypt_more, METH_VARARGS},
+ {"decrypt", (PyCFunction)rotorobj_decrypt, METH_VARARGS},
+ {"decryptmore", (PyCFunction)rotorobj_decrypt_more, METH_VARARGS},
{"setkey", (PyCFunction)rotorobj_setkey, METH_VARARGS},
{NULL, NULL} /* sentinel */
};
@@ -611,7 +611,7 @@ rotor_rotor(PyObject *self, PyObject *args)
static struct PyMethodDef
rotor_methods[] = {
- {"newrotor", rotor_rotor, 1},
+ {"newrotor", rotor_rotor, METH_VARARGS},
{NULL, NULL} /* sentinel */
};
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index 9255bad..f6027ab 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -149,7 +149,7 @@ static PyObject *
signal_alarm(PyObject *self, PyObject *args)
{
int t;
- if (!PyArg_Parse(args, "i", &t))
+ if (!PyArg_ParseTuple(args, "i:alarm", &t))
return NULL;
/* alarm() returns the number of seconds remaining */
return PyInt_FromLong((long)alarm(t));
@@ -192,7 +192,7 @@ signal_signal(PyObject *self, PyObject *args)
int sig_num;
PyObject *old_handler;
void (*func)(int);
- if (!PyArg_Parse(args, "(iO)", &sig_num, &obj))
+ if (!PyArg_ParseTuple(args, "iO:signal", &sig_num, &obj))
return NULL;
#ifdef WITH_THREAD
if (PyThread_get_thread_ident() != main_thread) {
@@ -248,7 +248,7 @@ signal_getsignal(PyObject *self, PyObject *args)
{
int sig_num;
PyObject *old_handler;
- if (!PyArg_Parse(args, "i", &sig_num))
+ if (!PyArg_ParseTuple(args, "i:getsignal", &sig_num))
return NULL;
if (sig_num < 1 || sig_num >= NSIG) {
PyErr_SetString(PyExc_ValueError,
@@ -274,16 +274,16 @@ anything else -- the callable Python object used as a handler\n\
/* List of functions defined in the module */
static PyMethodDef signal_methods[] = {
#ifdef HAVE_ALARM
- {"alarm", signal_alarm, METH_OLDARGS, alarm_doc},
+ {"alarm", signal_alarm, METH_VARARGS, alarm_doc},
#endif
- {"signal", signal_signal, METH_OLDARGS, signal_doc},
- {"getsignal", signal_getsignal, METH_OLDARGS, getsignal_doc},
+ {"signal", signal_signal, METH_VARARGS, signal_doc},
+ {"getsignal", signal_getsignal, METH_VARARGS, getsignal_doc},
#ifdef HAVE_PAUSE
{"pause", (PyCFunction)signal_pause,
METH_NOARGS,pause_doc},
#endif
{"default_int_handler", signal_default_int_handler,
- METH_OLDARGS, default_int_handler_doc},
+ METH_VARARGS, default_int_handler_doc},
{NULL, NULL} /* sentinel */
};
diff --git a/Modules/sunaudiodev.c b/Modules/sunaudiodev.c
index 514cab6..506ee33 100644
--- a/Modules/sunaudiodev.c
+++ b/Modules/sunaudiodev.c
@@ -58,7 +58,7 @@ newsadobject(PyObject *args)
char* opendev;
/* Check arg for r/w/rw */
- if (!PyArg_Parse(args, "s", &mode))
+ if (!PyArg_ParseTuple(args, "s", &mode))
return NULL;
if (strcmp(mode, "r") == 0)
imode = 0;
@@ -133,7 +133,7 @@ sad_read(sadobject *self, PyObject *args)
char *cp;
PyObject *rv;
- if (!PyArg_Parse(args, "i", &size))
+ if (!PyArg_ParseTuple(args, "i:read", &size))
return NULL;
rv = PyString_FromStringAndSize(NULL, size);
if (rv == NULL)
@@ -169,7 +169,7 @@ sad_write(sadobject *self, PyObject *args)
char *cp;
int count, size;
- if (!PyArg_Parse(args, "s#", &cp, &size))
+ if (!PyArg_ParseTuple(args, "s#:write", &cp, &size))
return NULL;
count = write(self->x_fd, cp, size);
@@ -188,12 +188,10 @@ sad_write(sadobject *self, PyObject *args)
}
static PyObject *
-sad_getinfo(sadobject *self, PyObject *args)
+sad_getinfo(sadobject *self)
{
sadstatusobject *rv;
- if (!PyArg_Parse(args, ""))
- return NULL;
if (!(rv = sads_alloc()))
return NULL;
@@ -222,12 +220,10 @@ sad_setinfo(sadobject *self, sadstatusobject *arg)
}
static PyObject *
-sad_ibufcount(sadobject *self, PyObject *args)
+sad_ibufcount(sadobject *self)
{
audio_info_t ai;
- if (!PyArg_Parse(args, ""))
- return NULL;
if (ioctl(self->x_fd, AUDIO_GETINFO, &ai) < 0) {
PyErr_SetFromErrno(SunAudioError);
return NULL;
@@ -236,12 +232,10 @@ sad_ibufcount(sadobject *self, PyObject *args)
}
static PyObject *
-sad_obufcount(sadobject *self, PyObject *args)
+sad_obufcount(sadobject *self)
{
audio_info_t ai;
- if (!PyArg_Parse(args, ""))
- return NULL;
if (ioctl(self->x_fd, AUDIO_GETINFO, &ai) < 0) {
PyErr_SetFromErrno(SunAudioError);
return NULL;
@@ -254,11 +248,8 @@ sad_obufcount(sadobject *self, PyObject *args)
}
static PyObject *
-sad_drain(sadobject *self, PyObject *args)
+sad_drain(sadobject *self)
{
-
- if (!PyArg_Parse(args, ""))
- return NULL;
if (ioctl(self->x_fd, AUDIO_DRAIN, 0) < 0) {
PyErr_SetFromErrno(SunAudioError);
return NULL;
@@ -269,12 +260,10 @@ sad_drain(sadobject *self, PyObject *args)
#ifdef SOLARIS
static PyObject *
-sad_getdev(sadobject *self, PyObject *args)
+sad_getdev(sadobject *self)
{
struct audio_device ad;
- if (!PyArg_Parse(args, ""))
- return NULL;
if (ioctl(self->x_fd, AUDIO_GETDEV, &ad) < 0) {
PyErr_SetFromErrno(SunAudioError);
return NULL;
@@ -284,11 +273,8 @@ sad_getdev(sadobject *self, PyObject *args)
#endif
static PyObject *
-sad_flush(sadobject *self, PyObject *args)
+sad_flush(sadobject *self)
{
-
- if (!PyArg_Parse(args, ""))
- return NULL;
if (ioctl(self->x_fd, I_FLUSH, FLUSHW) < 0) {
PyErr_SetFromErrno(SunAudioError);
return NULL;
@@ -298,11 +284,9 @@ sad_flush(sadobject *self, PyObject *args)
}
static PyObject *
-sad_close(sadobject *self, PyObject *args)
+sad_close(sadobject *self)
{
- if (!PyArg_Parse(args, ""))
- return NULL;
if (self->x_fd >= 0) {
close(self->x_fd);
self->x_fd = -1;
@@ -312,30 +296,27 @@ sad_close(sadobject *self, PyObject *args)
}
static PyObject *
-sad_fileno(sadobject *self, PyObject *args)
+sad_fileno(sadobject *self)
{
- if (!PyArg_Parse(args, ""))
- return NULL;
-
return PyInt_FromLong(self->x_fd);
}
static PyMethodDef sad_methods[] = {
- { "read", (PyCFunction)sad_read, METH_OLDARGS },
- { "write", (PyCFunction)sad_write, METH_OLDARGS },
- { "ibufcount", (PyCFunction)sad_ibufcount, METH_OLDARGS },
- { "obufcount", (PyCFunction)sad_obufcount, METH_OLDARGS },
+ { "read", (PyCFunction)sad_read, METH_VARARGS },
+ { "write", (PyCFunction)sad_write, METH_VARARGS },
+ { "ibufcount", (PyCFunction)sad_ibufcount, METH_NOARGS },
+ { "obufcount", (PyCFunction)sad_obufcount, METH_NOARGS },
#define CTL_METHODS 4
- { "getinfo", (PyCFunction)sad_getinfo, METH_OLDARGS },
- { "setinfo", (PyCFunction)sad_setinfo, METH_OLDARGS },
- { "drain", (PyCFunction)sad_drain, METH_OLDARGS },
- { "flush", (PyCFunction)sad_flush, METH_OLDARGS },
+ { "getinfo", (PyCFunction)sad_getinfo, METH_NOARGS },
+ { "setinfo", (PyCFunction)sad_setinfo, METH_O},
+ { "drain", (PyCFunction)sad_drain, METH_NOARGS },
+ { "flush", (PyCFunction)sad_flush, METH_NOARGS },
#ifdef SOLARIS
- { "getdev", (PyCFunction)sad_getdev, METH_OLDARGS },
+ { "getdev", (PyCFunction)sad_getdev, METH_NOARGS },
#endif
- { "close", (PyCFunction)sad_close, METH_OLDARGS },
- { "fileno", (PyCFunction)sad_fileno, METH_OLDARGS },
+ { "close", (PyCFunction)sad_close, METH_NOARGS },
+ { "fileno", (PyCFunction)sad_fileno, METH_NOARGS },
{NULL, NULL} /* sentinel */
};
@@ -465,7 +446,7 @@ sadopen(PyObject *self, PyObject *args)
}
static PyMethodDef sunaudiodev_methods[] = {
- { "open", sadopen, METH_OLDARGS },
+ { "open", sadopen, METH_VARARGS },
{ 0, 0 },
};
diff --git a/Modules/threadmodule.c b/Modules/threadmodule.c
index 21313b5..2459c3b 100644
--- a/Modules/threadmodule.c
+++ b/Modules/threadmodule.c
@@ -54,14 +54,10 @@ lock_dealloc(lockobject *self)
static PyObject *
lock_PyThread_acquire_lock(lockobject *self, PyObject *args)
{
- int i;
+ int i = 1;
- if (args != NULL) {
- if (!PyArg_Parse(args, "i", &i))
- return NULL;
- }
- else
- i = 1;
+ if (!PyArg_ParseTuple(args, "|i:acquire", &i))
+ return NULL;
Py_BEGIN_ALLOW_THREADS
i = PyThread_acquire_lock(self->lock_lock, i);
@@ -127,9 +123,9 @@ Return whether the lock is in the locked state.";
static PyMethodDef lock_methods[] = {
{"acquire_lock", (PyCFunction)lock_PyThread_acquire_lock,
- METH_OLDARGS, acquire_doc},
+ METH_VARARGS, acquire_doc},
{"acquire", (PyCFunction)lock_PyThread_acquire_lock,
- METH_OLDARGS, acquire_doc},
+ METH_VARARGS, acquire_doc},
{"release_lock", (PyCFunction)lock_PyThread_release_lock,
METH_NOARGS, release_doc},
{"release", (PyCFunction)lock_PyThread_release_lock,
@@ -279,7 +275,7 @@ static PyObject *
thread_PyThread_exit_prog(PyObject *self, PyObject *args)
{
int sts;
- if (!PyArg_Parse(args, "i", &sts))
+ if (!PyArg_ParseTuple(args, "i:exit_prog", &sts))
return NULL;
Py_Exit(sts); /* Calls PyThread_exit_prog(sts) or _PyThread_exit_prog(sts) */
for (;;) { } /* Should not be reached */
@@ -339,7 +335,8 @@ static PyMethodDef thread_methods[] = {
{"get_ident", (PyCFunction)thread_get_ident,
METH_NOARGS, get_ident_doc},
#ifndef NO_EXIT_PROG
- {"exit_prog", (PyCFunction)thread_PyThread_exit_prog},
+ {"exit_prog", (PyCFunction)thread_PyThread_exit_prog,
+ METH_VARARGS},
#endif
{NULL, NULL} /* sentinel */
};