Make use of METH_O and METH_NOARGS where possible.

Use Py_UnpackTuple instead of PyArg_ParseTuple where possible.
This commit is contained in:
Georg Brandl 2006-05-29 21:04:52 +00:00
parent fd9a4b19e9
commit 96a8c3954c
26 changed files with 187 additions and 405 deletions

View File

@ -1041,7 +1041,7 @@ DB_append(DBObject* self, PyObject* args)
DBT key, data; DBT key, data;
DB_TXN *txn = NULL; DB_TXN *txn = NULL;
if (!PyArg_ParseTuple(args, "O|O:append", &dataobj, &txnobj)) if (!PyArg_UnpackTuple(args, "append", 1, 2, &dataobj, &txnobj))
return NULL; return NULL;
CHECK_DB_NOT_CLOSED(self); CHECK_DB_NOT_CLOSED(self);
@ -2895,7 +2895,7 @@ DB_keys(DBObject* self, PyObject* args)
PyObject* txnobj = NULL; PyObject* txnobj = NULL;
DB_TXN *txn = NULL; DB_TXN *txn = NULL;
if (!PyArg_ParseTuple(args,"|O:keys", &txnobj)) if (!PyArg_UnpackTuple(args, "keys", 0, 1, &txnobj))
return NULL; return NULL;
if (!checkTxnObj(txnobj, &txn)) if (!checkTxnObj(txnobj, &txn))
return NULL; return NULL;
@ -2909,7 +2909,7 @@ DB_items(DBObject* self, PyObject* args)
PyObject* txnobj = NULL; PyObject* txnobj = NULL;
DB_TXN *txn = NULL; DB_TXN *txn = NULL;
if (!PyArg_ParseTuple(args,"|O:items", &txnobj)) if (!PyArg_UnpackTuple(args, "items", 0, 1, &txnobj))
return NULL; return NULL;
if (!checkTxnObj(txnobj, &txn)) if (!checkTxnObj(txnobj, &txn))
return NULL; return NULL;
@ -2923,7 +2923,7 @@ DB_values(DBObject* self, PyObject* args)
PyObject* txnobj = NULL; PyObject* txnobj = NULL;
DB_TXN *txn = NULL; DB_TXN *txn = NULL;
if (!PyArg_ParseTuple(args,"|O:values", &txnobj)) if (!PyArg_UnpackTuple(args, "values", 0, 1, &txnobj))
return NULL; return NULL;
if (!checkTxnObj(txnobj, &txn)) if (!checkTxnObj(txnobj, &txn))
return NULL; return NULL;

View File

@ -48,21 +48,12 @@ one argument, the encoding name in all lower case letters, and return\n\
a tuple of functions (encoder, decoder, stream_reader, stream_writer)."); a tuple of functions (encoder, decoder, stream_reader, stream_writer).");
static static
PyObject *codec_register(PyObject *self, PyObject *args) PyObject *codec_register(PyObject *self, PyObject *search_function)
{ {
PyObject *search_function;
if (!PyArg_ParseTuple(args, "O:register", &search_function))
goto onError;
if (PyCodec_Register(search_function)) if (PyCodec_Register(search_function))
goto onError; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
onError:
return NULL;
} }
PyDoc_STRVAR(lookup__doc__, PyDoc_STRVAR(lookup__doc__,
@ -77,12 +68,9 @@ PyObject *codec_lookup(PyObject *self, PyObject *args)
char *encoding; char *encoding;
if (!PyArg_ParseTuple(args, "s:lookup", &encoding)) if (!PyArg_ParseTuple(args, "s:lookup", &encoding))
goto onError; return NULL;
return _PyCodec_Lookup(encoding); return _PyCodec_Lookup(encoding);
onError:
return NULL;
} }
PyDoc_STRVAR(encode__doc__, PyDoc_STRVAR(encode__doc__,
@ -116,13 +104,7 @@ codec_encode(PyObject *self, PyObject *args)
#endif #endif
/* Encode via the codec registry */ /* Encode via the codec registry */
v = PyCodec_Encode(v, encoding, errors); return PyCodec_Encode(v, encoding, errors);
if (v == NULL)
goto onError;
return v;
onError:
return NULL;
} }
PyDoc_STRVAR(decode__doc__, PyDoc_STRVAR(decode__doc__,
@ -156,13 +138,7 @@ codec_decode(PyObject *self, PyObject *args)
#endif #endif
/* Decode via the codec registry */ /* Decode via the codec registry */
v = PyCodec_Decode(v, encoding, errors); return PyCodec_Decode(v, encoding, errors);
if (v == NULL)
goto onError;
return v;
onError:
return NULL;
} }
/* --- Helpers ------------------------------------------------------------ */ /* --- Helpers ------------------------------------------------------------ */
@ -171,22 +147,11 @@ static
PyObject *codec_tuple(PyObject *unicode, PyObject *codec_tuple(PyObject *unicode,
Py_ssize_t len) Py_ssize_t len)
{ {
PyObject *v,*w; PyObject *v;
if (unicode == NULL) if (unicode == NULL)
return NULL; return NULL;
v = PyTuple_New(2); v = Py_BuildValue("On", unicode, len);
if (v == NULL) { Py_DECREF(unicode);
Py_DECREF(unicode);
return NULL;
}
PyTuple_SET_ITEM(v,0,unicode);
w = PyInt_FromSsize_t(len);
if (w == NULL) {
Py_DECREF(v);
return NULL;
}
PyTuple_SET_ITEM(v,1,w);
return v; return v;
} }
@ -419,7 +384,7 @@ utf_16_ex_decode(PyObject *self,
final ? NULL : &consumed); final ? NULL : &consumed);
if (unicode == NULL) if (unicode == NULL)
return NULL; return NULL;
tuple = Py_BuildValue("Oii", unicode, consumed, byteorder); tuple = Py_BuildValue("Oni", unicode, consumed, byteorder);
Py_DECREF(unicode); Py_DECREF(unicode);
return tuple; return tuple;
} }
@ -604,8 +569,8 @@ utf_7_encode(PyObject *self,
return NULL; return NULL;
v = codec_tuple(PyUnicode_EncodeUTF7(PyUnicode_AS_UNICODE(str), v = codec_tuple(PyUnicode_EncodeUTF7(PyUnicode_AS_UNICODE(str),
PyUnicode_GET_SIZE(str), PyUnicode_GET_SIZE(str),
0, 0,
0, 0,
errors), errors),
PyUnicode_GET_SIZE(str)); PyUnicode_GET_SIZE(str));
Py_DECREF(str); Py_DECREF(str);
@ -876,8 +841,7 @@ static PyObject *register_error(PyObject *self, PyObject *args)
return NULL; return NULL;
if (PyCodec_RegisterError(name, handler)) if (PyCodec_RegisterError(name, handler))
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(lookup_error__doc__, PyDoc_STRVAR(lookup_error__doc__,
@ -899,7 +863,7 @@ static PyObject *lookup_error(PyObject *self, PyObject *args)
/* --- Module API --------------------------------------------------------- */ /* --- Module API --------------------------------------------------------- */
static PyMethodDef _codecs_functions[] = { static PyMethodDef _codecs_functions[] = {
{"register", codec_register, METH_VARARGS, {"register", codec_register, METH_O,
register__doc__}, register__doc__},
{"lookup", codec_lookup, METH_VARARGS, {"lookup", codec_lookup, METH_VARARGS,
lookup__doc__}, lookup__doc__},

View File

@ -77,13 +77,10 @@ EVP_dealloc(PyObject *ptr)
PyDoc_STRVAR(EVP_copy__doc__, "Return a copy of the hash object."); PyDoc_STRVAR(EVP_copy__doc__, "Return a copy of the hash object.");
static PyObject * static PyObject *
EVP_copy(EVPobject *self, PyObject *args) EVP_copy(EVPobject *self, PyObject *unused)
{ {
EVPobject *newobj; EVPobject *newobj;
if (!PyArg_ParseTuple(args, ":copy"))
return NULL;
if ( (newobj = newEVPobject(self->name))==NULL) if ( (newobj = newEVPobject(self->name))==NULL)
return NULL; return NULL;
@ -95,16 +92,13 @@ PyDoc_STRVAR(EVP_digest__doc__,
"Return the digest value as a string of binary data."); "Return the digest value as a string of binary data.");
static PyObject * static PyObject *
EVP_digest(EVPobject *self, PyObject *args) EVP_digest(EVPobject *self, PyObject *unused)
{ {
unsigned char digest[EVP_MAX_MD_SIZE]; unsigned char digest[EVP_MAX_MD_SIZE];
EVP_MD_CTX temp_ctx; EVP_MD_CTX temp_ctx;
PyObject *retval; PyObject *retval;
unsigned int digest_size; unsigned int digest_size;
if (!PyArg_ParseTuple(args, ":digest"))
return NULL;
EVP_MD_CTX_copy(&temp_ctx, &self->ctx); EVP_MD_CTX_copy(&temp_ctx, &self->ctx);
digest_size = EVP_MD_CTX_size(&temp_ctx); digest_size = EVP_MD_CTX_size(&temp_ctx);
EVP_DigestFinal(&temp_ctx, digest, NULL); EVP_DigestFinal(&temp_ctx, digest, NULL);
@ -118,7 +112,7 @@ PyDoc_STRVAR(EVP_hexdigest__doc__,
"Return the digest value as a string of hexadecimal digits."); "Return the digest value as a string of hexadecimal digits.");
static PyObject * static PyObject *
EVP_hexdigest(EVPobject *self, PyObject *args) EVP_hexdigest(EVPobject *self, PyObject *unused)
{ {
unsigned char digest[EVP_MAX_MD_SIZE]; unsigned char digest[EVP_MAX_MD_SIZE];
EVP_MD_CTX temp_ctx; EVP_MD_CTX temp_ctx;
@ -126,9 +120,6 @@ EVP_hexdigest(EVPobject *self, PyObject *args)
char *hex_digest; char *hex_digest;
unsigned int i, j, digest_size; unsigned int i, j, digest_size;
if (!PyArg_ParseTuple(args, ":hexdigest"))
return NULL;
/* Get the raw (binary) digest value */ /* Get the raw (binary) digest value */
EVP_MD_CTX_copy(&temp_ctx, &self->ctx); EVP_MD_CTX_copy(&temp_ctx, &self->ctx);
digest_size = EVP_MD_CTX_size(&temp_ctx); digest_size = EVP_MD_CTX_size(&temp_ctx);
@ -182,9 +173,9 @@ EVP_update(EVPobject *self, PyObject *args)
static PyMethodDef EVP_methods[] = { static PyMethodDef EVP_methods[] = {
{"update", (PyCFunction)EVP_update, METH_VARARGS, EVP_update__doc__}, {"update", (PyCFunction)EVP_update, METH_VARARGS, EVP_update__doc__},
{"digest", (PyCFunction)EVP_digest, METH_VARARGS, EVP_digest__doc__}, {"digest", (PyCFunction)EVP_digest, METH_NOARGS, EVP_digest__doc__},
{"hexdigest", (PyCFunction)EVP_hexdigest, METH_VARARGS, EVP_hexdigest__doc__}, {"hexdigest", (PyCFunction)EVP_hexdigest, METH_NOARGS, EVP_hexdigest__doc__},
{"copy", (PyCFunction)EVP_copy, METH_VARARGS, EVP_copy__doc__}, {"copy", (PyCFunction)EVP_copy, METH_NOARGS, EVP_copy__doc__},
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };

View File

@ -1058,7 +1058,7 @@ profiler_runcall(ProfilerObject *self, PyObject *args)
PyObject *callkw = NULL; PyObject *callkw = NULL;
PyObject *callable; PyObject *callable;
if (PyArg_ParseTuple(args, "O|OO:runcall", if (PyArg_UnpackTuple(args, "runcall", 1, 3,
&callable, &callargs, &callkw)) { &callable, &callargs, &callkw)) {
if (is_available(self)) { if (is_available(self)) {
do_start(self); do_start(self);
@ -1575,23 +1575,18 @@ PyDoc_STR(
; ;
static PyObject * static PyObject *
hotshot_resolution(PyObject *unused, PyObject *args) hotshot_resolution(PyObject *self, PyObject *unused)
{ {
PyObject *result = NULL; if (timeofday_diff == 0) {
calibrate();
if (PyArg_ParseTuple(args, ":resolution")) { calibrate();
if (timeofday_diff == 0) { calibrate();
calibrate();
calibrate();
calibrate();
}
#ifdef MS_WINDOWS
result = Py_BuildValue("ii", timeofday_diff, frequency.LowPart);
#else
result = Py_BuildValue("ii", timeofday_diff, rusage_diff);
#endif
} }
return result; #ifdef MS_WINDOWS
return Py_BuildValue("ii", timeofday_diff, frequency.LowPart);
#else
return Py_BuildValue("ii", timeofday_diff, rusage_diff);
#endif
} }
@ -1599,7 +1594,7 @@ static PyMethodDef functions[] = {
{"coverage", hotshot_coverage, METH_VARARGS, coverage__doc__}, {"coverage", hotshot_coverage, METH_VARARGS, coverage__doc__},
{"profiler", hotshot_profiler, METH_VARARGS, profiler__doc__}, {"profiler", hotshot_profiler, METH_VARARGS, profiler__doc__},
{"logreader", hotshot_logreader, METH_VARARGS, logreader__doc__}, {"logreader", hotshot_logreader, METH_VARARGS, logreader__doc__},
{"resolution", hotshot_resolution, METH_VARARGS, resolution__doc__}, {"resolution", hotshot_resolution, METH_NOARGS, resolution__doc__},
{NULL, NULL} {NULL, NULL}
}; };

View File

@ -281,7 +281,7 @@ PyLocale_strcoll(PyObject* self, PyObject* args)
wchar_t *ws1 = NULL, *ws2 = NULL; wchar_t *ws1 = NULL, *ws2 = NULL;
int rel1 = 0, rel2 = 0, len1, len2; int rel1 = 0, rel2 = 0, len1, len2;
if (!PyArg_ParseTuple(args, "OO:strcoll", &os1, &os2)) if (!PyArg_UnpackTuple(args, "strcoll", 2, 2, &os1, &os2))
return NULL; return NULL;
/* If both arguments are byte strings, use strcoll. */ /* If both arguments are byte strings, use strcoll. */
if (PyString_Check(os1) && PyString_Check(os2)) if (PyString_Check(os1) && PyString_Check(os2))

View File

@ -2891,7 +2891,7 @@ match_start(MatchObject* self, PyObject* args)
int index; int index;
PyObject* index_ = Py_False; /* zero */ PyObject* index_ = Py_False; /* zero */
if (!PyArg_ParseTuple(args, "|O:start", &index_)) if (!PyArg_UnpackTuple(args, "start", 0, 1, &index_))
return NULL; return NULL;
index = match_getindex(self, index_); index = match_getindex(self, index_);
@ -2914,7 +2914,7 @@ match_end(MatchObject* self, PyObject* args)
int index; int index;
PyObject* index_ = Py_False; /* zero */ PyObject* index_ = Py_False; /* zero */
if (!PyArg_ParseTuple(args, "|O:end", &index_)) if (!PyArg_UnpackTuple(args, "end", 0, 1, &index_))
return NULL; return NULL;
index = match_getindex(self, index_); index = match_getindex(self, index_);
@ -2964,7 +2964,7 @@ match_span(MatchObject* self, PyObject* args)
int index; int index;
PyObject* index_ = Py_False; /* zero */ PyObject* index_ = Py_False; /* zero */
if (!PyArg_ParseTuple(args, "|O:span", &index_)) if (!PyArg_UnpackTuple(args, "span", 0, 1, &index_))
return NULL; return NULL;
index = match_getindex(self, index_); index = match_getindex(self, index_);

View File

@ -5110,29 +5110,23 @@ noload(Unpicklerobject *self)
static PyObject * static PyObject *
Unpickler_load(Unpicklerobject *self, PyObject *args) Unpickler_load(Unpicklerobject *self, PyObject *unused)
{ {
if (!( PyArg_ParseTuple(args, ":load")))
return NULL;
return load(self); return load(self);
} }
static PyObject * static PyObject *
Unpickler_noload(Unpicklerobject *self, PyObject *args) Unpickler_noload(Unpicklerobject *self, PyObject *unused)
{ {
if (!( PyArg_ParseTuple(args, ":noload")))
return NULL;
return noload(self); return noload(self);
} }
static struct PyMethodDef Unpickler_methods[] = { static struct PyMethodDef Unpickler_methods[] = {
{"load", (PyCFunction)Unpickler_load, METH_VARARGS, {"load", (PyCFunction)Unpickler_load, METH_NOARGS,
PyDoc_STR("load() -- Load a pickle") PyDoc_STR("load() -- Load a pickle")
}, },
{"noload", (PyCFunction)Unpickler_noload, METH_VARARGS, {"noload", (PyCFunction)Unpickler_noload, METH_NOARGS,
PyDoc_STR( PyDoc_STR(
"noload() -- not load a pickle, but go through most of the motions\n" "noload() -- not load a pickle, but go through most of the motions\n"
"\n" "\n"
@ -5214,12 +5208,8 @@ newUnpicklerobject(PyObject *f)
static PyObject * static PyObject *
get_Unpickler(PyObject *self, PyObject *args) get_Unpickler(PyObject *self, PyObject *file)
{ {
PyObject *file;
if (!( PyArg_ParseTuple(args, "O:Unpickler", &file)))
return NULL;
return (PyObject *)newUnpicklerobject(file); return (PyObject *)newUnpicklerobject(file);
} }
@ -5428,13 +5418,10 @@ cpm_dumps(PyObject *self, PyObject *args, PyObject *kwds)
/* load(fileobj). */ /* load(fileobj). */
static PyObject * static PyObject *
cpm_load(PyObject *self, PyObject *args) cpm_load(PyObject *self, PyObject *ob)
{ {
Unpicklerobject *unpickler = 0; Unpicklerobject *unpickler = 0;
PyObject *ob, *res = NULL; PyObject *res = NULL;
if (!( PyArg_ParseTuple(args, "O:load", &ob)))
goto finally;
if (!( unpickler = newUnpicklerobject(ob))) if (!( unpickler = newUnpicklerobject(ob)))
goto finally; goto finally;
@ -5519,7 +5506,7 @@ static struct PyMethodDef cPickle_methods[] = {
"See the Pickler docstring for the meaning of optional argument proto.") "See the Pickler docstring for the meaning of optional argument proto.")
}, },
{"load", (PyCFunction)cpm_load, METH_VARARGS, {"load", (PyCFunction)cpm_load, METH_O,
PyDoc_STR("load(file) -- Load a pickle from the given file")}, PyDoc_STR("load(file) -- Load a pickle from the given file")},
{"loads", (PyCFunction)cpm_loads, METH_VARARGS, {"loads", (PyCFunction)cpm_loads, METH_VARARGS,
@ -5550,7 +5537,7 @@ static struct PyMethodDef cPickle_methods[] = {
"object, or any other custom object that meets this interface.\n") "object, or any other custom object that meets this interface.\n")
}, },
{"Unpickler", (PyCFunction)get_Unpickler, METH_VARARGS, {"Unpickler", (PyCFunction)get_Unpickler, METH_O,
PyDoc_STR("Unpickler(file) -- Create an unpickler.")}, PyDoc_STR("Unpickler(file) -- Create an unpickler.")},
{ NULL, NULL } { NULL, NULL }

View File

@ -1302,7 +1302,7 @@ mbstreamreader_read(MultibyteStreamReaderObject *self, PyObject *args)
PyObject *sizeobj = NULL; PyObject *sizeobj = NULL;
Py_ssize_t size; Py_ssize_t size;
if (!PyArg_ParseTuple(args, "|O:read", &sizeobj)) if (!PyArg_UnpackTuple(args, "read", 0, 1, &sizeobj))
return NULL; return NULL;
if (sizeobj == Py_None || sizeobj == NULL) if (sizeobj == Py_None || sizeobj == NULL)
@ -1323,7 +1323,7 @@ mbstreamreader_readline(MultibyteStreamReaderObject *self, PyObject *args)
PyObject *sizeobj = NULL; PyObject *sizeobj = NULL;
Py_ssize_t size; Py_ssize_t size;
if (!PyArg_ParseTuple(args, "|O:readline", &sizeobj)) if (!PyArg_UnpackTuple(args, "readline", 0, 1, &sizeobj))
return NULL; return NULL;
if (sizeobj == Py_None || sizeobj == NULL) if (sizeobj == Py_None || sizeobj == NULL)
@ -1344,7 +1344,7 @@ mbstreamreader_readlines(MultibyteStreamReaderObject *self, PyObject *args)
PyObject *sizehintobj = NULL, *r, *sr; PyObject *sizehintobj = NULL, *r, *sr;
Py_ssize_t sizehint; Py_ssize_t sizehint;
if (!PyArg_ParseTuple(args, "|O:readlines", &sizehintobj)) if (!PyArg_UnpackTuple(args, "readlines", 0, 1, &sizehintobj))
return NULL; return NULL;
if (sizehintobj == Py_None || sizehintobj == NULL) if (sizehintobj == Py_None || sizehintobj == NULL)
@ -1532,13 +1532,8 @@ mbstreamwriter_iwrite(MultibyteStreamWriterObject *self,
} }
static PyObject * static PyObject *
mbstreamwriter_write(MultibyteStreamWriterObject *self, PyObject *args) mbstreamwriter_write(MultibyteStreamWriterObject *self, PyObject *strobj)
{ {
PyObject *strobj;
if (!PyArg_ParseTuple(args, "O:write", &strobj))
return NULL;
if (mbstreamwriter_iwrite(self, strobj)) if (mbstreamwriter_iwrite(self, strobj))
return NULL; return NULL;
else else
@ -1546,14 +1541,11 @@ mbstreamwriter_write(MultibyteStreamWriterObject *self, PyObject *args)
} }
static PyObject * static PyObject *
mbstreamwriter_writelines(MultibyteStreamWriterObject *self, PyObject *args) mbstreamwriter_writelines(MultibyteStreamWriterObject *self, PyObject *lines)
{ {
PyObject *lines, *strobj; PyObject *strobj;
int i, r; int i, r;
if (!PyArg_ParseTuple(args, "O:writelines", &lines))
return NULL;
if (!PySequence_Check(lines)) { if (!PySequence_Check(lines)) {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"arg must be a sequence object"); "arg must be a sequence object");
@ -1676,9 +1668,9 @@ mbstreamwriter_dealloc(MultibyteStreamWriterObject *self)
static struct PyMethodDef mbstreamwriter_methods[] = { static struct PyMethodDef mbstreamwriter_methods[] = {
{"write", (PyCFunction)mbstreamwriter_write, {"write", (PyCFunction)mbstreamwriter_write,
METH_VARARGS, NULL}, METH_O, NULL},
{"writelines", (PyCFunction)mbstreamwriter_writelines, {"writelines", (PyCFunction)mbstreamwriter_writelines,
METH_VARARGS, NULL}, METH_O, NULL},
{"reset", (PyCFunction)mbstreamwriter_reset, {"reset", (PyCFunction)mbstreamwriter_reset,
METH_NOARGS, NULL}, METH_NOARGS, NULL},
{NULL, NULL}, {NULL, NULL},

View File

@ -168,10 +168,8 @@ static PyMappingMethods dbm_as_mapping = {
}; };
static PyObject * static PyObject *
dbm__close(register dbmobject *dp, PyObject *args) dbm__close(register dbmobject *dp, PyObject *unused)
{ {
if (!PyArg_ParseTuple(args, ":close"))
return NULL;
if (dp->di_dbm) if (dp->di_dbm)
dbm_close(dp->di_dbm); dbm_close(dp->di_dbm);
dp->di_dbm = NULL; dp->di_dbm = NULL;
@ -180,14 +178,12 @@ dbm__close(register dbmobject *dp, PyObject *args)
} }
static PyObject * static PyObject *
dbm_keys(register dbmobject *dp, PyObject *args) dbm_keys(register dbmobject *dp, PyObject *unused)
{ {
register PyObject *v, *item; register PyObject *v, *item;
datum key; datum key;
int err; int err;
if (!PyArg_ParseTuple(args, ":keys"))
return NULL;
check_dbmobject_open(dp); check_dbmobject_open(dp);
v = PyList_New(0); v = PyList_New(0);
if (v == NULL) if (v == NULL)
@ -277,9 +273,9 @@ dbm_setdefault(register dbmobject *dp, PyObject *args)
} }
static PyMethodDef dbm_methods[] = { static PyMethodDef dbm_methods[] = {
{"close", (PyCFunction)dbm__close, METH_VARARGS, {"close", (PyCFunction)dbm__close, METH_NOARGS,
"close()\nClose the database."}, "close()\nClose the database."},
{"keys", (PyCFunction)dbm_keys, METH_VARARGS, {"keys", (PyCFunction)dbm_keys, METH_NOARGS,
"keys() -> list\nReturn a list of all keys in the database."}, "keys() -> list\nReturn a list of all keys in the database."},
{"has_key", (PyCFunction)dbm_has_key, METH_VARARGS, {"has_key", (PyCFunction)dbm_has_key, METH_VARARGS,
"has_key(key} -> boolean\nReturn true iff key is in the database."}, "has_key(key} -> boolean\nReturn true iff key is in the database."},

View File

@ -189,10 +189,8 @@ PyDoc_STRVAR(dbm_close__doc__,
Closes the database."); Closes the database.");
static PyObject * static PyObject *
dbm_close(register dbmobject *dp, PyObject *args) dbm_close(register dbmobject *dp, PyObject *unused)
{ {
if (!PyArg_ParseTuple(args, ":close"))
return NULL;
if (dp->di_dbm) if (dp->di_dbm)
gdbm_close(dp->di_dbm); gdbm_close(dp->di_dbm);
dp->di_dbm = NULL; dp->di_dbm = NULL;
@ -205,7 +203,7 @@ PyDoc_STRVAR(dbm_keys__doc__,
Get a list of all keys in the database."); Get a list of all keys in the database.");
static PyObject * static PyObject *
dbm_keys(register dbmobject *dp, PyObject *args) dbm_keys(register dbmobject *dp, PyObject *unused)
{ {
register PyObject *v, *item; register PyObject *v, *item;
datum key, nextkey; datum key, nextkey;
@ -215,9 +213,6 @@ dbm_keys(register dbmobject *dp, PyObject *args)
PyErr_BadInternalCall(); PyErr_BadInternalCall();
return NULL; return NULL;
} }
if (!PyArg_ParseTuple(args, ":keys"))
return NULL;
check_dbmobject_open(dp); check_dbmobject_open(dp);
v = PyList_New(0); v = PyList_New(0);
@ -269,13 +264,11 @@ hash values, and won't be sorted by the key values. This method\n\
returns the starting key."); returns the starting key.");
static PyObject * static PyObject *
dbm_firstkey(register dbmobject *dp, PyObject *args) dbm_firstkey(register dbmobject *dp, PyObject *unused)
{ {
register PyObject *v; register PyObject *v;
datum key; datum key;
if (!PyArg_ParseTuple(args, ":firstkey"))
return NULL;
check_dbmobject_open(dp); check_dbmobject_open(dp);
key = gdbm_firstkey(dp->di_dbm); key = gdbm_firstkey(dp->di_dbm);
if (key.dptr) { if (key.dptr) {
@ -330,10 +323,8 @@ by using this reorganization; otherwise, deleted file space will be\n\
kept and reused as new (key,value) pairs are added."); kept and reused as new (key,value) pairs are added.");
static PyObject * static PyObject *
dbm_reorganize(register dbmobject *dp, PyObject *args) dbm_reorganize(register dbmobject *dp, PyObject *unused)
{ {
if (!PyArg_ParseTuple(args, ":reorganize"))
return NULL;
check_dbmobject_open(dp); check_dbmobject_open(dp);
errno = 0; errno = 0;
if (gdbm_reorganize(dp->di_dbm) < 0) { if (gdbm_reorganize(dp->di_dbm) < 0) {
@ -353,10 +344,8 @@ When the database has been opened in fast mode, this method forces\n\
any unwritten data to be written to the disk."); any unwritten data to be written to the disk.");
static PyObject * static PyObject *
dbm_sync(register dbmobject *dp, PyObject *args) dbm_sync(register dbmobject *dp, PyObject *unused)
{ {
if (!PyArg_ParseTuple(args, ":sync"))
return NULL;
check_dbmobject_open(dp); check_dbmobject_open(dp);
gdbm_sync(dp->di_dbm); gdbm_sync(dp->di_dbm);
Py_INCREF(Py_None); Py_INCREF(Py_None);
@ -364,13 +353,13 @@ dbm_sync(register dbmobject *dp, PyObject *args)
} }
static PyMethodDef dbm_methods[] = { static PyMethodDef dbm_methods[] = {
{"close", (PyCFunction)dbm_close, METH_VARARGS, dbm_close__doc__}, {"close", (PyCFunction)dbm_close, METH_NOARGS, dbm_close__doc__},
{"keys", (PyCFunction)dbm_keys, METH_VARARGS, dbm_keys__doc__}, {"keys", (PyCFunction)dbm_keys, METH_NOARGS, dbm_keys__doc__},
{"has_key", (PyCFunction)dbm_has_key, METH_VARARGS, dbm_has_key__doc__}, {"has_key", (PyCFunction)dbm_has_key, METH_VARARGS, dbm_has_key__doc__},
{"firstkey", (PyCFunction)dbm_firstkey,METH_VARARGS, dbm_firstkey__doc__}, {"firstkey", (PyCFunction)dbm_firstkey,METH_NOARGS, dbm_firstkey__doc__},
{"nextkey", (PyCFunction)dbm_nextkey, METH_VARARGS, dbm_nextkey__doc__}, {"nextkey", (PyCFunction)dbm_nextkey, METH_VARARGS, dbm_nextkey__doc__},
{"reorganize",(PyCFunction)dbm_reorganize,METH_VARARGS, dbm_reorganize__doc__}, {"reorganize",(PyCFunction)dbm_reorganize,METH_NOARGS, dbm_reorganize__doc__},
{"sync", (PyCFunction)dbm_sync, METH_VARARGS, dbm_sync__doc__}, {"sync", (PyCFunction)dbm_sync, METH_NOARGS, dbm_sync__doc__},
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };

View File

@ -219,24 +219,18 @@ lad_write(lad_t *self, PyObject *args)
} }
static PyObject * static PyObject *
lad_close(lad_t *self, PyObject *args) lad_close(lad_t *self, PyObject *unused)
{ {
if (!PyArg_ParseTuple(args, ":close"))
return NULL;
if (self->x_fd >= 0) { if (self->x_fd >= 0) {
close(self->x_fd); close(self->x_fd);
self->x_fd = -1; self->x_fd = -1;
} }
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *
lad_fileno(lad_t *self, PyObject *args) lad_fileno(lad_t *self, PyObject *unused)
{ {
if (!PyArg_ParseTuple(args, ":fileno"))
return NULL;
return PyInt_FromLong(self->x_fd); return PyInt_FromLong(self->x_fd);
} }
@ -341,13 +335,11 @@ _ssize(lad_t *self, int *nchannels, int *ssize)
/* bufsize returns the size of the hardware audio buffer in number /* bufsize returns the size of the hardware audio buffer in number
of samples */ of samples */
static PyObject * static PyObject *
lad_bufsize(lad_t *self, PyObject *args) lad_bufsize(lad_t *self, PyObject *unused)
{ {
audio_buf_info ai; audio_buf_info ai;
int nchannels=0, ssize=0; int nchannels=0, ssize=0;
if (!PyArg_ParseTuple(args, ":bufsize")) return NULL;
if (_ssize(self, &nchannels, &ssize) < 0 || !ssize || !nchannels) { if (_ssize(self, &nchannels, &ssize) < 0 || !ssize || !nchannels) {
PyErr_SetFromErrno(LinuxAudioError); PyErr_SetFromErrno(LinuxAudioError);
return NULL; return NULL;
@ -362,14 +354,11 @@ lad_bufsize(lad_t *self, PyObject *args)
/* obufcount returns the number of samples that are available in the /* obufcount returns the number of samples that are available in the
hardware for playing */ hardware for playing */
static PyObject * static PyObject *
lad_obufcount(lad_t *self, PyObject *args) lad_obufcount(lad_t *self, PyObject *unused)
{ {
audio_buf_info ai; audio_buf_info ai;
int nchannels=0, ssize=0; int nchannels=0, ssize=0;
if (!PyArg_ParseTuple(args, ":obufcount"))
return NULL;
if (_ssize(self, &nchannels, &ssize) < 0 || !ssize || !nchannels) { if (_ssize(self, &nchannels, &ssize) < 0 || !ssize || !nchannels) {
PyErr_SetFromErrno(LinuxAudioError); PyErr_SetFromErrno(LinuxAudioError);
return NULL; return NULL;
@ -385,14 +374,11 @@ lad_obufcount(lad_t *self, PyObject *args)
/* obufcount returns the number of samples that can be played without /* obufcount returns the number of samples that can be played without
blocking */ blocking */
static PyObject * static PyObject *
lad_obuffree(lad_t *self, PyObject *args) lad_obuffree(lad_t *self, PyObject *unused)
{ {
audio_buf_info ai; audio_buf_info ai;
int nchannels=0, ssize=0; int nchannels=0, ssize=0;
if (!PyArg_ParseTuple(args, ":obuffree"))
return NULL;
if (_ssize(self, &nchannels, &ssize) < 0 || !ssize || !nchannels) { if (_ssize(self, &nchannels, &ssize) < 0 || !ssize || !nchannels) {
PyErr_SetFromErrno(LinuxAudioError); PyErr_SetFromErrno(LinuxAudioError);
return NULL; return NULL;
@ -406,27 +392,21 @@ lad_obuffree(lad_t *self, PyObject *args)
/* Flush the device */ /* Flush the device */
static PyObject * static PyObject *
lad_flush(lad_t *self, PyObject *args) lad_flush(lad_t *self, PyObject *unused)
{ {
if (!PyArg_ParseTuple(args, ":flush")) return NULL;
if (ioctl(self->x_fd, SNDCTL_DSP_SYNC, NULL) == -1) { if (ioctl(self->x_fd, SNDCTL_DSP_SYNC, NULL) == -1) {
PyErr_SetFromErrno(LinuxAudioError); PyErr_SetFromErrno(LinuxAudioError);
return NULL; return NULL;
} }
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *
lad_getptr(lad_t *self, PyObject *args) lad_getptr(lad_t *self, PyObject *unused)
{ {
count_info info; count_info info;
int req; int req;
if (!PyArg_ParseTuple(args, ":getptr"))
return NULL;
if (self->x_mode == O_RDONLY) if (self->x_mode == O_RDONLY)
req = SNDCTL_DSP_GETIPTR; req = SNDCTL_DSP_GETIPTR;
else else
@ -443,12 +423,12 @@ static PyMethodDef lad_methods[] = {
{ "write", (PyCFunction)lad_write, METH_VARARGS }, { "write", (PyCFunction)lad_write, METH_VARARGS },
{ "setparameters", (PyCFunction)lad_setparameters, METH_VARARGS }, { "setparameters", (PyCFunction)lad_setparameters, METH_VARARGS },
{ "bufsize", (PyCFunction)lad_bufsize, METH_VARARGS }, { "bufsize", (PyCFunction)lad_bufsize, METH_VARARGS },
{ "obufcount", (PyCFunction)lad_obufcount, METH_VARARGS }, { "obufcount", (PyCFunction)lad_obufcount, METH_NOARGS },
{ "obuffree", (PyCFunction)lad_obuffree, METH_VARARGS }, { "obuffree", (PyCFunction)lad_obuffree, METH_NOARGS },
{ "flush", (PyCFunction)lad_flush, METH_VARARGS }, { "flush", (PyCFunction)lad_flush, METH_NOARGS },
{ "close", (PyCFunction)lad_close, METH_VARARGS }, { "close", (PyCFunction)lad_close, METH_NOARGS },
{ "fileno", (PyCFunction)lad_fileno, METH_VARARGS }, { "fileno", (PyCFunction)lad_fileno, METH_NOARGS },
{ "getptr", (PyCFunction)lad_getptr, METH_VARARGS }, { "getptr", (PyCFunction)lad_getptr, METH_NOARGS },
{ NULL, NULL} /* sentinel */ { NULL, NULL} /* sentinel */
}; };

View File

@ -114,10 +114,8 @@ mmap_object_dealloc(mmap_object *m_obj)
} }
static PyObject * static PyObject *
mmap_close_method(mmap_object *self, PyObject *args) mmap_close_method(mmap_object *self, PyObject *unused)
{ {
if (!PyArg_ParseTuple(args, ":close"))
return NULL;
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
/* For each resource we maintain, we need to check /* For each resource we maintain, we need to check
the value is valid, and if so, free the resource the value is valid, and if so, free the resource
@ -175,11 +173,9 @@ do { \
static PyObject * static PyObject *
mmap_read_byte_method(mmap_object *self, mmap_read_byte_method(mmap_object *self,
PyObject *args) PyObject *unused)
{ {
CHECK_VALID(NULL); CHECK_VALID(NULL);
if (!PyArg_ParseTuple(args, ":read_byte"))
return NULL;
if (self->pos < self->size) { if (self->pos < self->size) {
char value = self->data[self->pos]; char value = self->data[self->pos];
self->pos += 1; self->pos += 1;
@ -192,7 +188,7 @@ mmap_read_byte_method(mmap_object *self,
static PyObject * static PyObject *
mmap_read_line_method(mmap_object *self, mmap_read_line_method(mmap_object *self,
PyObject *args) PyObject *unused)
{ {
char *start = self->data+self->pos; char *start = self->data+self->pos;
char *eof = self->data+self->size; char *eof = self->data+self->size;
@ -200,8 +196,6 @@ mmap_read_line_method(mmap_object *self,
PyObject *result; PyObject *result;
CHECK_VALID(NULL); CHECK_VALID(NULL);
if (!PyArg_ParseTuple(args, ":readline"))
return NULL;
eol = memchr(start, '\n', self->size - self->pos); eol = memchr(start, '\n', self->size - self->pos);
if (!eol) if (!eol)
@ -332,11 +326,9 @@ mmap_write_byte_method(mmap_object *self,
static PyObject * static PyObject *
mmap_size_method(mmap_object *self, mmap_size_method(mmap_object *self,
PyObject *args) PyObject *unused)
{ {
CHECK_VALID(NULL); CHECK_VALID(NULL);
if (!PyArg_ParseTuple(args, ":size"))
return NULL;
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
if (self->file_handle != INVALID_HANDLE_VALUE) { if (self->file_handle != INVALID_HANDLE_VALUE) {
@ -472,11 +464,9 @@ mmap_resize_method(mmap_object *self,
} }
static PyObject * static PyObject *
mmap_tell_method(mmap_object *self, PyObject *args) mmap_tell_method(mmap_object *self, PyObject *unused)
{ {
CHECK_VALID(NULL); CHECK_VALID(NULL);
if (!PyArg_ParseTuple(args, ":tell"))
return NULL;
return PyInt_FromLong((long) self->pos); return PyInt_FromLong((long) self->pos);
} }
@ -578,17 +568,17 @@ mmap_move_method(mmap_object *self, PyObject *args)
} }
static struct PyMethodDef mmap_object_methods[] = { static struct PyMethodDef mmap_object_methods[] = {
{"close", (PyCFunction) mmap_close_method, METH_VARARGS}, {"close", (PyCFunction) mmap_close_method, METH_NOARGS},
{"find", (PyCFunction) mmap_find_method, METH_VARARGS}, {"find", (PyCFunction) mmap_find_method, METH_VARARGS},
{"flush", (PyCFunction) mmap_flush_method, METH_VARARGS}, {"flush", (PyCFunction) mmap_flush_method, METH_VARARGS},
{"move", (PyCFunction) mmap_move_method, METH_VARARGS}, {"move", (PyCFunction) mmap_move_method, METH_VARARGS},
{"read", (PyCFunction) mmap_read_method, METH_VARARGS}, {"read", (PyCFunction) mmap_read_method, METH_VARARGS},
{"read_byte", (PyCFunction) mmap_read_byte_method, METH_VARARGS}, {"read_byte", (PyCFunction) mmap_read_byte_method, METH_NOARGS},
{"readline", (PyCFunction) mmap_read_line_method, METH_VARARGS}, {"readline", (PyCFunction) mmap_read_line_method, METH_NOARGS},
{"resize", (PyCFunction) mmap_resize_method, METH_VARARGS}, {"resize", (PyCFunction) mmap_resize_method, METH_VARARGS},
{"seek", (PyCFunction) mmap_seek_method, METH_VARARGS}, {"seek", (PyCFunction) mmap_seek_method, METH_VARARGS},
{"size", (PyCFunction) mmap_size_method, METH_VARARGS}, {"size", (PyCFunction) mmap_size_method, METH_NOARGS},
{"tell", (PyCFunction) mmap_tell_method, METH_VARARGS}, {"tell", (PyCFunction) mmap_tell_method, METH_NOARGS},
{"write", (PyCFunction) mmap_write_method, METH_VARARGS}, {"write", (PyCFunction) mmap_write_method, METH_VARARGS},
{"write_byte", (PyCFunction) mmap_write_byte_method, METH_VARARGS}, {"write_byte", (PyCFunction) mmap_write_byte_method, METH_VARARGS},
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */

View File

@ -296,12 +296,10 @@ _do_ioctl_0(int fd, PyObject *args, char *fname, int cmd)
*/ */
static PyObject * static PyObject *
oss_nonblock(oss_audio_t *self, PyObject *args) oss_nonblock(oss_audio_t *self, PyObject *unused)
{ {
/* Hmmm: it doesn't appear to be possible to return to blocking /* Hmmm: it doesn't appear to be possible to return to blocking
mode once we're in non-blocking mode! */ mode once we're in non-blocking mode! */
if (!PyArg_ParseTuple(args, ":nonblock"))
return NULL;
if (ioctl(self->fd, SNDCTL_DSP_NONBLOCK, NULL) == -1) if (ioctl(self->fd, SNDCTL_DSP_NONBLOCK, NULL) == -1)
return PyErr_SetFromErrno(PyExc_IOError); return PyErr_SetFromErrno(PyExc_IOError);
Py_INCREF(Py_None); Py_INCREF(Py_None);
@ -315,11 +313,9 @@ oss_setfmt(oss_audio_t *self, PyObject *args)
} }
static PyObject * static PyObject *
oss_getfmts(oss_audio_t *self, PyObject *args) oss_getfmts(oss_audio_t *self, PyObject *unused)
{ {
int mask; int mask;
if (!PyArg_ParseTuple(args, ":getfmts"))
return NULL;
if (ioctl(self->fd, SNDCTL_DSP_GETFMTS, &mask) == -1) if (ioctl(self->fd, SNDCTL_DSP_GETFMTS, &mask) == -1)
return PyErr_SetFromErrno(PyExc_IOError); return PyErr_SetFromErrno(PyExc_IOError);
return PyInt_FromLong(mask); return PyInt_FromLong(mask);
@ -459,11 +455,8 @@ oss_writeall(oss_audio_t *self, PyObject *args)
} }
static PyObject * static PyObject *
oss_close(oss_audio_t *self, PyObject *args) oss_close(oss_audio_t *self, PyObject *unused)
{ {
if (!PyArg_ParseTuple(args, ":close"))
return NULL;
if (self->fd >= 0) { if (self->fd >= 0) {
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
close(self->fd); close(self->fd);
@ -475,10 +468,8 @@ oss_close(oss_audio_t *self, PyObject *args)
} }
static PyObject * static PyObject *
oss_fileno(oss_audio_t *self, PyObject *args) oss_fileno(oss_audio_t *self, PyObject *unused)
{ {
if (!PyArg_ParseTuple(args, ":fileno"))
return NULL;
return PyInt_FromLong(self->fd); return PyInt_FromLong(self->fd);
} }
@ -578,13 +569,11 @@ _ssize(oss_audio_t *self, int *nchannels, int *ssize)
/* bufsize returns the size of the hardware audio buffer in number /* bufsize returns the size of the hardware audio buffer in number
of samples */ of samples */
static PyObject * static PyObject *
oss_bufsize(oss_audio_t *self, PyObject *args) oss_bufsize(oss_audio_t *self, PyObject *unused)
{ {
audio_buf_info ai; audio_buf_info ai;
int nchannels=0, ssize=0; int nchannels=0, ssize=0;
if (!PyArg_ParseTuple(args, ":bufsize")) return NULL;
if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) { if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) {
PyErr_SetFromErrno(PyExc_IOError); PyErr_SetFromErrno(PyExc_IOError);
return NULL; return NULL;
@ -599,14 +588,11 @@ oss_bufsize(oss_audio_t *self, PyObject *args)
/* obufcount returns the number of samples that are available in the /* obufcount returns the number of samples that are available in the
hardware for playing */ hardware for playing */
static PyObject * static PyObject *
oss_obufcount(oss_audio_t *self, PyObject *args) oss_obufcount(oss_audio_t *self, PyObject *unused)
{ {
audio_buf_info ai; audio_buf_info ai;
int nchannels=0, ssize=0; int nchannels=0, ssize=0;
if (!PyArg_ParseTuple(args, ":obufcount"))
return NULL;
if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) { if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) {
PyErr_SetFromErrno(PyExc_IOError); PyErr_SetFromErrno(PyExc_IOError);
return NULL; return NULL;
@ -622,14 +608,11 @@ oss_obufcount(oss_audio_t *self, PyObject *args)
/* obufcount returns the number of samples that can be played without /* obufcount returns the number of samples that can be played without
blocking */ blocking */
static PyObject * static PyObject *
oss_obuffree(oss_audio_t *self, PyObject *args) oss_obuffree(oss_audio_t *self, PyObject *unused)
{ {
audio_buf_info ai; audio_buf_info ai;
int nchannels=0, ssize=0; int nchannels=0, ssize=0;
if (!PyArg_ParseTuple(args, ":obuffree"))
return NULL;
if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) { if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) {
PyErr_SetFromErrno(PyExc_IOError); PyErr_SetFromErrno(PyExc_IOError);
return NULL; return NULL;
@ -642,14 +625,11 @@ oss_obuffree(oss_audio_t *self, PyObject *args)
} }
static PyObject * static PyObject *
oss_getptr(oss_audio_t *self, PyObject *args) oss_getptr(oss_audio_t *self, PyObject *unused)
{ {
count_info info; count_info info;
int req; int req;
if (!PyArg_ParseTuple(args, ":getptr"))
return NULL;
if (self->mode == O_RDONLY) if (self->mode == O_RDONLY)
req = SNDCTL_DSP_GETIPTR; req = SNDCTL_DSP_GETIPTR;
else else
@ -667,11 +647,8 @@ oss_getptr(oss_audio_t *self, PyObject *args)
*/ */
static PyObject * static PyObject *
oss_mixer_close(oss_mixer_t *self, PyObject *args) oss_mixer_close(oss_mixer_t *self, PyObject *unused)
{ {
if (!PyArg_ParseTuple(args, ":close"))
return NULL;
if (self->fd >= 0) { if (self->fd >= 0) {
close(self->fd); close(self->fd);
self->fd = -1; self->fd = -1;
@ -681,10 +658,8 @@ oss_mixer_close(oss_mixer_t *self, PyObject *args)
} }
static PyObject * static PyObject *
oss_mixer_fileno(oss_mixer_t *self, PyObject *args) oss_mixer_fileno(oss_mixer_t *self, PyObject *unused)
{ {
if (!PyArg_ParseTuple(args, ":fileno"))
return NULL;
return PyInt_FromLong(self->fd); return PyInt_FromLong(self->fd);
} }
@ -782,13 +757,13 @@ static PyMethodDef oss_methods[] = {
{ "read", (PyCFunction)oss_read, METH_VARARGS }, { "read", (PyCFunction)oss_read, METH_VARARGS },
{ "write", (PyCFunction)oss_write, METH_VARARGS }, { "write", (PyCFunction)oss_write, METH_VARARGS },
{ "writeall", (PyCFunction)oss_writeall, METH_VARARGS }, { "writeall", (PyCFunction)oss_writeall, METH_VARARGS },
{ "close", (PyCFunction)oss_close, METH_VARARGS }, { "close", (PyCFunction)oss_close, METH_NOARGS },
{ "fileno", (PyCFunction)oss_fileno, METH_VARARGS }, { "fileno", (PyCFunction)oss_fileno, METH_NOARGS },
/* Simple ioctl wrappers */ /* Simple ioctl wrappers */
{ "nonblock", (PyCFunction)oss_nonblock, METH_VARARGS }, { "nonblock", (PyCFunction)oss_nonblock, METH_NOARGS },
{ "setfmt", (PyCFunction)oss_setfmt, METH_VARARGS }, { "setfmt", (PyCFunction)oss_setfmt, METH_VARARGS },
{ "getfmts", (PyCFunction)oss_getfmts, METH_VARARGS }, { "getfmts", (PyCFunction)oss_getfmts, METH_NOARGS },
{ "channels", (PyCFunction)oss_channels, METH_VARARGS }, { "channels", (PyCFunction)oss_channels, METH_VARARGS },
{ "speed", (PyCFunction)oss_speed, METH_VARARGS }, { "speed", (PyCFunction)oss_speed, METH_VARARGS },
{ "sync", (PyCFunction)oss_sync, METH_VARARGS }, { "sync", (PyCFunction)oss_sync, METH_VARARGS },
@ -797,10 +772,10 @@ static PyMethodDef oss_methods[] = {
/* Convenience methods -- wrap a couple of ioctls together */ /* Convenience methods -- wrap a couple of ioctls together */
{ "setparameters", (PyCFunction)oss_setparameters, METH_VARARGS }, { "setparameters", (PyCFunction)oss_setparameters, METH_VARARGS },
{ "bufsize", (PyCFunction)oss_bufsize, METH_VARARGS }, { "bufsize", (PyCFunction)oss_bufsize, METH_NOARGS },
{ "obufcount", (PyCFunction)oss_obufcount, METH_VARARGS }, { "obufcount", (PyCFunction)oss_obufcount, METH_NOARGS },
{ "obuffree", (PyCFunction)oss_obuffree, METH_VARARGS }, { "obuffree", (PyCFunction)oss_obuffree, METH_NOARGS },
{ "getptr", (PyCFunction)oss_getptr, METH_VARARGS }, { "getptr", (PyCFunction)oss_getptr, METH_NOARGS },
/* Aliases for backwards compatibility */ /* Aliases for backwards compatibility */
{ "flush", (PyCFunction)oss_sync, METH_VARARGS }, { "flush", (PyCFunction)oss_sync, METH_VARARGS },
@ -810,8 +785,8 @@ static PyMethodDef oss_methods[] = {
static PyMethodDef oss_mixer_methods[] = { static PyMethodDef oss_mixer_methods[] = {
/* Regular file method - OSS mixers are ioctl-only interface */ /* Regular file method - OSS mixers are ioctl-only interface */
{ "close", (PyCFunction)oss_mixer_close, METH_VARARGS }, { "close", (PyCFunction)oss_mixer_close, METH_NOARGS },
{ "fileno", (PyCFunction)oss_mixer_fileno, METH_VARARGS }, { "fileno", (PyCFunction)oss_mixer_fileno, METH_NOARGS },
/* Simple ioctl wrappers */ /* Simple ioctl wrappers */
{ "controls", (PyCFunction)oss_mixer_controls, METH_VARARGS }, { "controls", (PyCFunction)oss_mixer_controls, METH_VARARGS },

View File

@ -5282,14 +5282,11 @@ PyDoc_STRVAR(posix_setgroups__doc__,
Set the groups of the current process to list."); Set the groups of the current process to list.");
static PyObject * static PyObject *
posix_setgroups(PyObject *self, PyObject *args) posix_setgroups(PyObject *self, PyObject *groups)
{ {
PyObject *groups;
int i, len; int i, len;
gid_t grouplist[MAX_GROUPS]; gid_t grouplist[MAX_GROUPS];
if (!PyArg_ParseTuple(args, "O:setgid", &groups))
return NULL;
if (!PySequence_Check(groups)) { if (!PySequence_Check(groups)) {
PyErr_SetString(PyExc_TypeError, "setgroups argument must be a sequence"); PyErr_SetString(PyExc_TypeError, "setgroups argument must be a sequence");
return NULL; return NULL;
@ -8020,7 +8017,7 @@ static PyMethodDef posix_methods[] = {
{"setgid", posix_setgid, METH_VARARGS, posix_setgid__doc__}, {"setgid", posix_setgid, METH_VARARGS, posix_setgid__doc__},
#endif /* HAVE_SETGID */ #endif /* HAVE_SETGID */
#ifdef HAVE_SETGROUPS #ifdef HAVE_SETGROUPS
{"setgroups", posix_setgroups, METH_VARARGS, posix_setgroups__doc__}, {"setgroups", posix_setgroups, METH_O, posix_setgroups__doc__},
#endif /* HAVE_SETGROUPS */ #endif /* HAVE_SETGROUPS */
#ifdef HAVE_GETPGID #ifdef HAVE_GETPGID
{"getpgid", posix_getpgid, METH_VARARGS, posix_getpgid__doc__}, {"getpgid", posix_getpgid, METH_VARARGS, posix_getpgid__doc__},

View File

@ -981,16 +981,12 @@ PyDoc_STRVAR(xmlparse_ParseFile__doc__,
Parse XML data from file-like object."); Parse XML data from file-like object.");
static PyObject * static PyObject *
xmlparse_ParseFile(xmlparseobject *self, PyObject *args) xmlparse_ParseFile(xmlparseobject *self, PyObject *f)
{ {
int rv = 1; int rv = 1;
PyObject *f;
FILE *fp; FILE *fp;
PyObject *readmethod = NULL; PyObject *readmethod = NULL;
if (!PyArg_ParseTuple(args, "O:ParseFile", &f))
return NULL;
if (PyFile_Check(f)) { if (PyFile_Check(f)) {
fp = PyFile_AsFile(f); fp = PyFile_AsFile(f);
} }
@ -1062,11 +1058,8 @@ PyDoc_STRVAR(xmlparse_GetBase__doc__,
Return base URL string for the parser."); Return base URL string for the parser.");
static PyObject * static PyObject *
xmlparse_GetBase(xmlparseobject *self, PyObject *args) xmlparse_GetBase(xmlparseobject *self, PyObject *unused)
{ {
if (!PyArg_ParseTuple(args, ":GetBase"))
return NULL;
return Py_BuildValue("z", XML_GetBase(self->itself)); return Py_BuildValue("z", XML_GetBase(self->itself));
} }
@ -1077,29 +1070,21 @@ If the event was generated by a large amount of text (such as a start tag\n\
for an element with many attributes), not all of the text may be available."); for an element with many attributes), not all of the text may be available.");
static PyObject * static PyObject *
xmlparse_GetInputContext(xmlparseobject *self, PyObject *args) xmlparse_GetInputContext(xmlparseobject *self, PyObject *unused)
{ {
PyObject *result = NULL; if (self->in_callback) {
int offset, size;
const char *buffer
= XML_GetInputContext(self->itself, &offset, &size);
if (PyArg_ParseTuple(args, ":GetInputContext")) { if (buffer != NULL)
if (self->in_callback) { return PyString_FromStringAndSize(buffer + offset,
int offset, size; size - offset);
const char *buffer else
= XML_GetInputContext(self->itself, &offset, &size); Py_RETURN_NONE;
if (buffer != NULL)
result = PyString_FromStringAndSize(buffer + offset, size - offset);
else {
result = Py_None;
Py_INCREF(result);
}
}
else {
result = Py_None;
Py_INCREF(result);
}
} }
return result; else
Py_RETURN_NONE;
} }
PyDoc_STRVAR(xmlparse_ExternalEntityParserCreate__doc__, PyDoc_STRVAR(xmlparse_ExternalEntityParserCreate__doc__,
@ -1228,7 +1213,7 @@ xmlparse_UseForeignDTD(xmlparseobject *self, PyObject *args)
PyObject *flagobj = NULL; PyObject *flagobj = NULL;
XML_Bool flag = XML_TRUE; XML_Bool flag = XML_TRUE;
enum XML_Error rc; enum XML_Error rc;
if (!PyArg_ParseTuple(args, "|O:UseForeignDTD", &flagobj)) if (!PyArg_UnpackTuple(args, "UseForeignDTD", 0, 1, &flagobj))
return NULL; return NULL;
if (flagobj != NULL) if (flagobj != NULL)
flag = PyObject_IsTrue(flagobj) ? XML_TRUE : XML_FALSE; flag = PyObject_IsTrue(flagobj) ? XML_TRUE : XML_FALSE;
@ -1245,17 +1230,17 @@ static struct PyMethodDef xmlparse_methods[] = {
{"Parse", (PyCFunction)xmlparse_Parse, {"Parse", (PyCFunction)xmlparse_Parse,
METH_VARARGS, xmlparse_Parse__doc__}, METH_VARARGS, xmlparse_Parse__doc__},
{"ParseFile", (PyCFunction)xmlparse_ParseFile, {"ParseFile", (PyCFunction)xmlparse_ParseFile,
METH_VARARGS, xmlparse_ParseFile__doc__}, METH_O, xmlparse_ParseFile__doc__},
{"SetBase", (PyCFunction)xmlparse_SetBase, {"SetBase", (PyCFunction)xmlparse_SetBase,
METH_VARARGS, xmlparse_SetBase__doc__}, METH_VARARGS, xmlparse_SetBase__doc__},
{"GetBase", (PyCFunction)xmlparse_GetBase, {"GetBase", (PyCFunction)xmlparse_GetBase,
METH_VARARGS, xmlparse_GetBase__doc__}, METH_NOARGS, xmlparse_GetBase__doc__},
{"ExternalEntityParserCreate", (PyCFunction)xmlparse_ExternalEntityParserCreate, {"ExternalEntityParserCreate", (PyCFunction)xmlparse_ExternalEntityParserCreate,
METH_VARARGS, xmlparse_ExternalEntityParserCreate__doc__}, METH_VARARGS, xmlparse_ExternalEntityParserCreate__doc__},
{"SetParamEntityParsing", (PyCFunction)xmlparse_SetParamEntityParsing, {"SetParamEntityParsing", (PyCFunction)xmlparse_SetParamEntityParsing,
METH_VARARGS, xmlparse_SetParamEntityParsing__doc__}, METH_VARARGS, xmlparse_SetParamEntityParsing__doc__},
{"GetInputContext", (PyCFunction)xmlparse_GetInputContext, {"GetInputContext", (PyCFunction)xmlparse_GetInputContext,
METH_VARARGS, xmlparse_GetInputContext__doc__}, METH_NOARGS, xmlparse_GetInputContext__doc__},
#if XML_COMBINED_VERSION >= 19505 #if XML_COMBINED_VERSION >= 19505
{"UseForeignDTD", (PyCFunction)xmlparse_UseForeignDTD, {"UseForeignDTD", (PyCFunction)xmlparse_UseForeignDTD,
METH_VARARGS, xmlparse_UseForeignDTD__doc__}, METH_VARARGS, xmlparse_UseForeignDTD__doc__},

View File

@ -194,12 +194,9 @@ resource_setrlimit(PyObject *self, PyObject *args)
} }
static PyObject * static PyObject *
resource_getpagesize(PyObject *self, PyObject *args) resource_getpagesize(PyObject *self, PyObject *unused)
{ {
long pagesize = 0; long pagesize = 0;
if (!PyArg_ParseTuple(args, ":getpagesize"))
return NULL;
#if defined(HAVE_GETPAGESIZE) #if defined(HAVE_GETPAGESIZE)
pagesize = getpagesize(); pagesize = getpagesize();
#elif defined(HAVE_SYSCONF) #elif defined(HAVE_SYSCONF)
@ -221,7 +218,7 @@ resource_methods[] = {
{"getrusage", resource_getrusage, METH_VARARGS}, {"getrusage", resource_getrusage, METH_VARARGS},
{"getrlimit", resource_getrlimit, METH_VARARGS}, {"getrlimit", resource_getrlimit, METH_VARARGS},
{"setrlimit", resource_setrlimit, METH_VARARGS}, {"setrlimit", resource_setrlimit, METH_VARARGS},
{"getpagesize", resource_getpagesize, METH_VARARGS}, {"getpagesize", resource_getpagesize, METH_NOARGS},
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };

View File

@ -218,7 +218,7 @@ select_select(PyObject *self, PyObject *args)
int n; int n;
/* convert arguments */ /* convert arguments */
if (!PyArg_ParseTuple(args, "OOO|O:select", if (!PyArg_UnpackTuple(args, "select", 3, 4,
&ifdlist, &ofdlist, &efdlist, &tout)) &ifdlist, &ofdlist, &efdlist, &tout))
return NULL; return NULL;
@ -415,15 +415,11 @@ PyDoc_STRVAR(poll_unregister_doc,
Remove a file descriptor being tracked by the polling object."); Remove a file descriptor being tracked by the polling object.");
static PyObject * static PyObject *
poll_unregister(pollObject *self, PyObject *args) poll_unregister(pollObject *self, PyObject *o)
{ {
PyObject *o, *key; PyObject *key;
int fd; int fd;
if (!PyArg_ParseTuple(args, "O:unregister", &o)) {
return NULL;
}
fd = PyObject_AsFileDescriptor( o ); fd = PyObject_AsFileDescriptor( o );
if (fd == -1) if (fd == -1)
return NULL; return NULL;
@ -459,7 +455,7 @@ poll_poll(pollObject *self, PyObject *args)
int timeout = 0, poll_result, i, j; int timeout = 0, poll_result, i, j;
PyObject *value = NULL, *num = NULL; PyObject *value = NULL, *num = NULL;
if (!PyArg_ParseTuple(args, "|O:poll", &tout)) { if (!PyArg_UnpackTuple(args, "poll", 0, 1, &tout)) {
return NULL; return NULL;
} }
@ -548,7 +544,7 @@ static PyMethodDef poll_methods[] = {
{"register", (PyCFunction)poll_register, {"register", (PyCFunction)poll_register,
METH_VARARGS, poll_register_doc}, METH_VARARGS, poll_register_doc},
{"unregister", (PyCFunction)poll_unregister, {"unregister", (PyCFunction)poll_unregister,
METH_VARARGS, poll_unregister_doc}, METH_O, poll_unregister_doc},
{"poll", (PyCFunction)poll_poll, {"poll", (PyCFunction)poll_poll,
METH_VARARGS, poll_poll_doc}, METH_VARARGS, poll_poll_doc},
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
@ -614,16 +610,9 @@ PyDoc_STRVAR(poll_doc,
unregistering file descriptors, and then polling them for I/O events."); unregistering file descriptors, and then polling them for I/O events.");
static PyObject * static PyObject *
select_poll(PyObject *self, PyObject *args) select_poll(PyObject *self, PyObject *unused)
{ {
pollObject *rv; return (PyObject *)newPollObject();
if (!PyArg_ParseTuple(args, ":poll"))
return NULL;
rv = newPollObject();
if ( rv == NULL )
return NULL;
return (PyObject *)rv;
} }
#ifdef __APPLE__ #ifdef __APPLE__
@ -684,7 +673,7 @@ On Windows, only sockets are supported; on Unix, all file descriptors.");
static PyMethodDef select_methods[] = { static PyMethodDef select_methods[] = {
{"select", select_select, METH_VARARGS, select_doc}, {"select", select_select, METH_VARARGS, select_doc},
#if defined(HAVE_POLL) #if defined(HAVE_POLL)
{"poll", select_poll, METH_VARARGS, poll_doc}, {"poll", select_poll, METH_NOARGS, poll_doc},
#endif /* HAVE_POLL */ #endif /* HAVE_POLL */
{0, 0}, /* sentinel */ {0, 0}, /* sentinel */
}; };

View File

@ -405,14 +405,10 @@ SHA_dealloc(PyObject *ptr)
PyDoc_STRVAR(SHA256_copy__doc__, "Return a copy of the hash object."); PyDoc_STRVAR(SHA256_copy__doc__, "Return a copy of the hash object.");
static PyObject * static PyObject *
SHA256_copy(SHAobject *self, PyObject *args) SHA256_copy(SHAobject *self, PyObject *unused)
{ {
SHAobject *newobj; SHAobject *newobj;
if (!PyArg_ParseTuple(args, ":copy")) {
return NULL;
}
if (((PyObject*)self)->ob_type == &SHA256type) { if (((PyObject*)self)->ob_type == &SHA256type) {
if ( (newobj = newSHA256object())==NULL) if ( (newobj = newSHA256object())==NULL)
return NULL; return NULL;
@ -429,14 +425,11 @@ PyDoc_STRVAR(SHA256_digest__doc__,
"Return the digest value as a string of binary data."); "Return the digest value as a string of binary data.");
static PyObject * static PyObject *
SHA256_digest(SHAobject *self, PyObject *args) SHA256_digest(SHAobject *self, PyObject *unused)
{ {
unsigned char digest[SHA_DIGESTSIZE]; unsigned char digest[SHA_DIGESTSIZE];
SHAobject temp; SHAobject temp;
if (!PyArg_ParseTuple(args, ":digest"))
return NULL;
SHAcopy(self, &temp); SHAcopy(self, &temp);
sha_final(digest, &temp); sha_final(digest, &temp);
return PyString_FromStringAndSize((const char *)digest, self->digestsize); return PyString_FromStringAndSize((const char *)digest, self->digestsize);
@ -446,7 +439,7 @@ PyDoc_STRVAR(SHA256_hexdigest__doc__,
"Return the digest value as a string of hexadecimal digits."); "Return the digest value as a string of hexadecimal digits.");
static PyObject * static PyObject *
SHA256_hexdigest(SHAobject *self, PyObject *args) SHA256_hexdigest(SHAobject *self, PyObject *unused)
{ {
unsigned char digest[SHA_DIGESTSIZE]; unsigned char digest[SHA_DIGESTSIZE];
SHAobject temp; SHAobject temp;
@ -454,9 +447,6 @@ SHA256_hexdigest(SHAobject *self, PyObject *args)
char *hex_digest; char *hex_digest;
int i, j; int i, j;
if (!PyArg_ParseTuple(args, ":hexdigest"))
return NULL;
/* Get the raw (binary) digest value */ /* Get the raw (binary) digest value */
SHAcopy(self, &temp); SHAcopy(self, &temp);
sha_final(digest, &temp); sha_final(digest, &temp);
@ -503,9 +493,9 @@ SHA256_update(SHAobject *self, PyObject *args)
} }
static PyMethodDef SHA_methods[] = { static PyMethodDef SHA_methods[] = {
{"copy", (PyCFunction)SHA256_copy, METH_VARARGS, SHA256_copy__doc__}, {"copy", (PyCFunction)SHA256_copy, METH_NOARGS, SHA256_copy__doc__},
{"digest", (PyCFunction)SHA256_digest, METH_VARARGS, SHA256_digest__doc__}, {"digest", (PyCFunction)SHA256_digest, METH_NOARGS, SHA256_digest__doc__},
{"hexdigest", (PyCFunction)SHA256_hexdigest, METH_VARARGS, SHA256_hexdigest__doc__}, {"hexdigest", (PyCFunction)SHA256_hexdigest, METH_NOARGS, SHA256_hexdigest__doc__},
{"update", (PyCFunction)SHA256_update, METH_VARARGS, SHA256_update__doc__}, {"update", (PyCFunction)SHA256_update, METH_VARARGS, SHA256_update__doc__},
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };

View File

@ -471,14 +471,10 @@ SHA512_dealloc(PyObject *ptr)
PyDoc_STRVAR(SHA512_copy__doc__, "Return a copy of the hash object."); PyDoc_STRVAR(SHA512_copy__doc__, "Return a copy of the hash object.");
static PyObject * static PyObject *
SHA512_copy(SHAobject *self, PyObject *args) SHA512_copy(SHAobject *self, PyObject *unused)
{ {
SHAobject *newobj; SHAobject *newobj;
if (!PyArg_ParseTuple(args, ":copy")) {
return NULL;
}
if (((PyObject*)self)->ob_type == &SHA512type) { if (((PyObject*)self)->ob_type == &SHA512type) {
if ( (newobj = newSHA512object())==NULL) if ( (newobj = newSHA512object())==NULL)
return NULL; return NULL;
@ -495,14 +491,11 @@ PyDoc_STRVAR(SHA512_digest__doc__,
"Return the digest value as a string of binary data."); "Return the digest value as a string of binary data.");
static PyObject * static PyObject *
SHA512_digest(SHAobject *self, PyObject *args) SHA512_digest(SHAobject *self, PyObject *unused)
{ {
unsigned char digest[SHA_DIGESTSIZE]; unsigned char digest[SHA_DIGESTSIZE];
SHAobject temp; SHAobject temp;
if (!PyArg_ParseTuple(args, ":digest"))
return NULL;
SHAcopy(self, &temp); SHAcopy(self, &temp);
sha512_final(digest, &temp); sha512_final(digest, &temp);
return PyString_FromStringAndSize((const char *)digest, self->digestsize); return PyString_FromStringAndSize((const char *)digest, self->digestsize);
@ -512,7 +505,7 @@ PyDoc_STRVAR(SHA512_hexdigest__doc__,
"Return the digest value as a string of hexadecimal digits."); "Return the digest value as a string of hexadecimal digits.");
static PyObject * static PyObject *
SHA512_hexdigest(SHAobject *self, PyObject *args) SHA512_hexdigest(SHAobject *self, PyObject *unused)
{ {
unsigned char digest[SHA_DIGESTSIZE]; unsigned char digest[SHA_DIGESTSIZE];
SHAobject temp; SHAobject temp;
@ -520,9 +513,6 @@ SHA512_hexdigest(SHAobject *self, PyObject *args)
char *hex_digest; char *hex_digest;
int i, j; int i, j;
if (!PyArg_ParseTuple(args, ":hexdigest"))
return NULL;
/* Get the raw (binary) digest value */ /* Get the raw (binary) digest value */
SHAcopy(self, &temp); SHAcopy(self, &temp);
sha512_final(digest, &temp); sha512_final(digest, &temp);
@ -538,7 +528,7 @@ SHA512_hexdigest(SHAobject *self, PyObject *args)
} }
/* Make hex version of the digest */ /* Make hex version of the digest */
for(i=j=0; i<self->digestsize; i++) { for (i=j=0; i<self->digestsize; i++) {
char c; char c;
c = (digest[i] >> 4) & 0xf; c = (digest[i] >> 4) & 0xf;
c = (c>9) ? c+'a'-10 : c + '0'; c = (c>9) ? c+'a'-10 : c + '0';
@ -569,9 +559,9 @@ SHA512_update(SHAobject *self, PyObject *args)
} }
static PyMethodDef SHA_methods[] = { static PyMethodDef SHA_methods[] = {
{"copy", (PyCFunction)SHA512_copy, METH_VARARGS, SHA512_copy__doc__}, {"copy", (PyCFunction)SHA512_copy, METH_NOARGS, SHA512_copy__doc__},
{"digest", (PyCFunction)SHA512_digest, METH_VARARGS, SHA512_digest__doc__}, {"digest", (PyCFunction)SHA512_digest, METH_NOARGS, SHA512_digest__doc__},
{"hexdigest", (PyCFunction)SHA512_hexdigest, METH_VARARGS, SHA512_hexdigest__doc__}, {"hexdigest", (PyCFunction)SHA512_hexdigest, METH_NOARGS, SHA512_hexdigest__doc__},
{"update", (PyCFunction)SHA512_update, METH_VARARGS, SHA512_update__doc__}, {"update", (PyCFunction)SHA512_update, METH_VARARGS, SHA512_update__doc__},
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };

View File

@ -358,13 +358,10 @@ SHA_dealloc(PyObject *ptr)
PyDoc_STRVAR(SHA_copy__doc__, "Return a copy of the hashing object."); PyDoc_STRVAR(SHA_copy__doc__, "Return a copy of the hashing object.");
static PyObject * static PyObject *
SHA_copy(SHAobject *self, PyObject *args) SHA_copy(SHAobject *self, PyObject *unused)
{ {
SHAobject *newobj; SHAobject *newobj;
if (!PyArg_ParseTuple(args, ":copy")) {
return NULL;
}
if ( (newobj = newSHAobject())==NULL) if ( (newobj = newSHAobject())==NULL)
return NULL; return NULL;
@ -376,14 +373,11 @@ PyDoc_STRVAR(SHA_digest__doc__,
"Return the digest value as a string of binary data."); "Return the digest value as a string of binary data.");
static PyObject * static PyObject *
SHA_digest(SHAobject *self, PyObject *args) SHA_digest(SHAobject *self, PyObject *unused)
{ {
unsigned char digest[SHA_DIGESTSIZE]; unsigned char digest[SHA_DIGESTSIZE];
SHAobject temp; SHAobject temp;
if (!PyArg_ParseTuple(args, ":digest"))
return NULL;
SHAcopy(self, &temp); SHAcopy(self, &temp);
sha_final(digest, &temp); sha_final(digest, &temp);
return PyString_FromStringAndSize((const char *)digest, sizeof(digest)); return PyString_FromStringAndSize((const char *)digest, sizeof(digest));
@ -393,7 +387,7 @@ PyDoc_STRVAR(SHA_hexdigest__doc__,
"Return the digest value as a string of hexadecimal digits."); "Return the digest value as a string of hexadecimal digits.");
static PyObject * static PyObject *
SHA_hexdigest(SHAobject *self, PyObject *args) SHA_hexdigest(SHAobject *self, PyObject *unused)
{ {
unsigned char digest[SHA_DIGESTSIZE]; unsigned char digest[SHA_DIGESTSIZE];
SHAobject temp; SHAobject temp;
@ -401,9 +395,6 @@ SHA_hexdigest(SHAobject *self, PyObject *args)
char *hex_digest; char *hex_digest;
int i, j; int i, j;
if (!PyArg_ParseTuple(args, ":hexdigest"))
return NULL;
/* Get the raw (binary) digest value */ /* Get the raw (binary) digest value */
SHAcopy(self, &temp); SHAcopy(self, &temp);
sha_final(digest, &temp); sha_final(digest, &temp);
@ -450,9 +441,9 @@ SHA_update(SHAobject *self, PyObject *args)
} }
static PyMethodDef SHA_methods[] = { static PyMethodDef SHA_methods[] = {
{"copy", (PyCFunction)SHA_copy, METH_VARARGS, SHA_copy__doc__}, {"copy", (PyCFunction)SHA_copy, METH_NOARGS, SHA_copy__doc__},
{"digest", (PyCFunction)SHA_digest, METH_VARARGS, SHA_digest__doc__}, {"digest", (PyCFunction)SHA_digest, METH_NOARGS, SHA_digest__doc__},
{"hexdigest", (PyCFunction)SHA_hexdigest, METH_VARARGS, SHA_hexdigest__doc__}, {"hexdigest", (PyCFunction)SHA_hexdigest, METH_NOARGS, SHA_hexdigest__doc__},
{"update", (PyCFunction)SHA_update, METH_VARARGS, SHA_update__doc__}, {"update", (PyCFunction)SHA_update, METH_VARARGS, SHA_update__doc__},
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };

View File

@ -2889,12 +2889,10 @@ static PyTypeObject sock_type = {
/*ARGSUSED*/ /*ARGSUSED*/
static PyObject * static PyObject *
socket_gethostname(PyObject *self, PyObject *args) socket_gethostname(PyObject *self, PyObject *unused)
{ {
char buf[1024]; char buf[1024];
int res; int res;
if (!PyArg_ParseTuple(args, ":gethostname"))
return NULL;
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
res = gethostname(buf, (int) sizeof buf - 1); res = gethostname(buf, (int) sizeof buf - 1);
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
@ -3986,13 +3984,13 @@ static PyMethodDef socket_methods[] = {
{"gethostbyaddr", socket_gethostbyaddr, {"gethostbyaddr", socket_gethostbyaddr,
METH_VARARGS, gethostbyaddr_doc}, METH_VARARGS, gethostbyaddr_doc},
{"gethostname", socket_gethostname, {"gethostname", socket_gethostname,
METH_VARARGS, gethostname_doc}, METH_NOARGS, gethostname_doc},
{"getservbyname", socket_getservbyname, {"getservbyname", socket_getservbyname,
METH_VARARGS, getservbyname_doc}, METH_VARARGS, getservbyname_doc},
{"getservbyport", socket_getservbyport, {"getservbyport", socket_getservbyport,
METH_VARARGS, getservbyport_doc}, METH_VARARGS, getservbyport_doc},
{"getprotobyname", socket_getprotobyname, {"getprotobyname", socket_getprotobyname,
METH_VARARGS,getprotobyname_doc}, METH_VARARGS, getprotobyname_doc},
#ifndef NO_DUP #ifndef NO_DUP
{"fromfd", socket_fromfd, {"fromfd", socket_fromfd,
METH_VARARGS, fromfd_doc}, METH_VARARGS, fromfd_doc},

View File

@ -98,10 +98,8 @@ syslog_syslog(PyObject * self, PyObject * args)
} }
static PyObject * static PyObject *
syslog_closelog(PyObject *self, PyObject *args) syslog_closelog(PyObject *self, PyObject *unused)
{ {
if (!PyArg_ParseTuple(args, ":closelog"))
return NULL;
closelog(); closelog();
Py_XDECREF(S_ident_o); Py_XDECREF(S_ident_o);
S_ident_o = NULL; S_ident_o = NULL;
@ -146,7 +144,7 @@ syslog_log_upto(PyObject *self, PyObject *args)
static PyMethodDef syslog_methods[] = { static PyMethodDef syslog_methods[] = {
{"openlog", syslog_openlog, METH_VARARGS}, {"openlog", syslog_openlog, METH_VARARGS},
{"closelog", syslog_closelog, METH_VARARGS}, {"closelog", syslog_closelog, METH_NOARGS},
{"syslog", syslog_syslog, METH_VARARGS}, {"syslog", syslog_syslog, METH_VARARGS},
{"setlogmask", syslog_setlogmask, METH_VARARGS}, {"setlogmask", syslog_setlogmask, METH_VARARGS},
{"LOG_MASK", syslog_log_mask, METH_VARARGS}, {"LOG_MASK", syslog_log_mask, METH_VARARGS},

View File

@ -456,7 +456,8 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
struct bootstate *boot; struct bootstate *boot;
long ident; long ident;
if (!PyArg_ParseTuple(fargs, "OO|O:start_new_thread", &func, &args, &keyw)) if (!PyArg_UnpackTuple(fargs, "start_new_thread", 2, 3,
&func, &args, &keyw))
return NULL; return NULL;
if (!PyCallable_Check(func)) { if (!PyCallable_Check(func)) {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,

View File

@ -123,11 +123,9 @@ _PyTime_DoubleToTimet(double x)
} }
static PyObject * static PyObject *
time_time(PyObject *self, PyObject *args) time_time(PyObject *self, PyObject *unused)
{ {
double secs; double secs;
if (!PyArg_ParseTuple(args, ":time"))
return NULL;
secs = floattime(); secs = floattime();
if (secs == 0.0) { if (secs == 0.0) {
PyErr_SetFromErrno(PyExc_IOError); PyErr_SetFromErrno(PyExc_IOError);
@ -153,10 +151,8 @@ Fractions of a second may be present if the system clock provides them.");
#endif #endif
static PyObject * static PyObject *
time_clock(PyObject *self, PyObject *args) time_clock(PyObject *self, PyObject *unused)
{ {
if (!PyArg_ParseTuple(args, ":clock"))
return NULL;
return PyFloat_FromDouble(((double)clock()) / CLOCKS_PER_SEC); return PyFloat_FromDouble(((double)clock()) / CLOCKS_PER_SEC);
} }
#endif /* HAVE_CLOCK */ #endif /* HAVE_CLOCK */
@ -164,16 +160,13 @@ time_clock(PyObject *self, PyObject *args)
#if defined(MS_WINDOWS) && !defined(__BORLANDC__) #if defined(MS_WINDOWS) && !defined(__BORLANDC__)
/* Due to Mark Hammond and Tim Peters */ /* Due to Mark Hammond and Tim Peters */
static PyObject * static PyObject *
time_clock(PyObject *self, PyObject *args) time_clock(PyObject *self, PyObject *unused)
{ {
static LARGE_INTEGER ctrStart; static LARGE_INTEGER ctrStart;
static double divisor = 0.0; static double divisor = 0.0;
LARGE_INTEGER now; LARGE_INTEGER now;
double diff; double diff;
if (!PyArg_ParseTuple(args, ":clock"))
return NULL;
if (divisor == 0.0) { if (divisor == 0.0) {
LARGE_INTEGER freq; LARGE_INTEGER freq;
QueryPerformanceCounter(&ctrStart); QueryPerformanceCounter(&ctrStart);
@ -509,7 +502,7 @@ time_asctime(PyObject *self, PyObject *args)
PyObject *tup = NULL; PyObject *tup = NULL;
struct tm buf; struct tm buf;
char *p; char *p;
if (!PyArg_ParseTuple(args, "|O:asctime", &tup)) if (!PyArg_UnpackTuple(args, "asctime", 0, 1, &tup))
return NULL; return NULL;
if (tup == NULL) { if (tup == NULL) {
time_t tt = time(NULL); time_t tt = time(NULL);
@ -536,7 +529,7 @@ time_ctime(PyObject *self, PyObject *args)
time_t tt; time_t tt;
char *p; char *p;
if (!PyArg_ParseTuple(args, "|O:ctime", &ot)) if (!PyArg_UnpackTuple(args, "ctime", 0, 1, &ot))
return NULL; return NULL;
if (ot == NULL || ot == Py_None) if (ot == NULL || ot == Py_None)
tt = time(NULL); tt = time(NULL);
@ -567,13 +560,10 @@ not present, current time as returned by localtime() is used.");
#ifdef HAVE_MKTIME #ifdef HAVE_MKTIME
static PyObject * static PyObject *
time_mktime(PyObject *self, PyObject *args) time_mktime(PyObject *self, PyObject *tup)
{ {
PyObject *tup;
struct tm buf; struct tm buf;
time_t tt; time_t tt;
if (!PyArg_ParseTuple(args, "O:mktime", &tup))
return NULL;
tt = time(&tt); tt = time(&tt);
buf = *localtime(&tt); buf = *localtime(&tt);
if (!gettmarg(tup, &buf)) if (!gettmarg(tup, &buf))
@ -597,13 +587,10 @@ Convert a time tuple in local time to seconds since the Epoch.");
void inittimezone(PyObject *module); void inittimezone(PyObject *module);
static PyObject * static PyObject *
time_tzset(PyObject *self, PyObject *args) time_tzset(PyObject *self, PyObject *unused)
{ {
PyObject* m; PyObject* m;
if (!PyArg_ParseTuple(args, ":tzset"))
return NULL;
m = PyImport_ImportModule("time"); m = PyImport_ImportModule("time");
if (m == NULL) { if (m == NULL) {
return NULL; return NULL;
@ -722,9 +709,9 @@ void inittimezone(PyObject *m) {
static PyMethodDef time_methods[] = { static PyMethodDef time_methods[] = {
{"time", time_time, METH_VARARGS, time_doc}, {"time", time_time, METH_NOARGS, time_doc},
#ifdef HAVE_CLOCK #ifdef HAVE_CLOCK
{"clock", time_clock, METH_VARARGS, clock_doc}, {"clock", time_clock, METH_NOARGS, clock_doc},
#endif #endif
{"sleep", time_sleep, METH_VARARGS, sleep_doc}, {"sleep", time_sleep, METH_VARARGS, sleep_doc},
{"gmtime", time_gmtime, METH_VARARGS, gmtime_doc}, {"gmtime", time_gmtime, METH_VARARGS, gmtime_doc},
@ -732,14 +719,14 @@ static PyMethodDef time_methods[] = {
{"asctime", time_asctime, METH_VARARGS, asctime_doc}, {"asctime", time_asctime, METH_VARARGS, asctime_doc},
{"ctime", time_ctime, METH_VARARGS, ctime_doc}, {"ctime", time_ctime, METH_VARARGS, ctime_doc},
#ifdef HAVE_MKTIME #ifdef HAVE_MKTIME
{"mktime", time_mktime, METH_VARARGS, mktime_doc}, {"mktime", time_mktime, METH_O, mktime_doc},
#endif #endif
#ifdef HAVE_STRFTIME #ifdef HAVE_STRFTIME
{"strftime", time_strftime, METH_VARARGS, strftime_doc}, {"strftime", time_strftime, METH_VARARGS, strftime_doc},
#endif #endif
{"strptime", time_strptime, METH_VARARGS, strptime_doc}, {"strptime", time_strptime, METH_VARARGS, strptime_doc},
#ifdef HAVE_WORKING_TZSET #ifdef HAVE_WORKING_TZSET
{"tzset", time_tzset, METH_VARARGS, tzset_doc}, {"tzset", time_tzset, METH_NOARGS, tzset_doc},
#endif #endif
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };

View File

@ -216,7 +216,7 @@ gen_throw(PyGenObject *gen, PyObject *args)
PyObject *tb = NULL; PyObject *tb = NULL;
PyObject *val = NULL; PyObject *val = NULL;
if (!PyArg_ParseTuple(args, "O|OO:throw", &typ, &val, &tb)) if (!PyArg_UnpackTuple(args, "throw", 1, 3, &typ, &val, &tb))
return NULL; return NULL;
/* First, check the traceback argument, replacing None with /* First, check the traceback argument, replacing None with

View File

@ -200,7 +200,7 @@ static PyObject *
sys_exit(PyObject *self, PyObject *args) sys_exit(PyObject *self, PyObject *args)
{ {
PyObject *exit_code = 0; PyObject *exit_code = 0;
if (!PyArg_ParseTuple(args, "|O:exit", &exit_code)) if (!PyArg_UnpackTuple(args, "exit", 0, 1, &exit_code))
return NULL; return NULL;
/* Raise SystemExit so callers may catch it or clean up. */ /* Raise SystemExit so callers may catch it or clean up. */
PyErr_SetObject(PyExc_SystemExit, exit_code); PyErr_SetObject(PyExc_SystemExit, exit_code);
@ -672,7 +672,7 @@ static PyObject *
sys_call_tracing(PyObject *self, PyObject *args) sys_call_tracing(PyObject *self, PyObject *args)
{ {
PyObject *func, *funcargs; PyObject *func, *funcargs;
if (!PyArg_ParseTuple(args, "OO:call_tracing", &func, &funcargs)) if (!PyArg_UnpackTuple(args, "call_tracing", 2, 2, &func, &funcargs))
return NULL; return NULL;
return _PyEval_CallTracing(func, funcargs); return _PyEval_CallTracing(func, funcargs);
} }