Remove many uses of PyArg_NoArgs macro, change METH_OLDARGS to METH_NOARGS.

This commit is contained in:
Neal Norwitz 2002-03-25 20:46:46 +00:00
parent 57f8e06e4f
commit 3a6f97850b
9 changed files with 65 additions and 122 deletions

View File

@ -118,6 +118,9 @@
#include "abstract.h"
#define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a))
/* PyArg_NoArgs should not be necessary.
Set ml_flags in the PyMethodDef to METH_NOARGS. */
#define PyArg_NoArgs(v) PyArg_Parse(v, "")
/* Convert a possibly signed character to a nonnegative int */

View File

@ -355,14 +355,12 @@ PyTypeObject PyCursesPanel_Type = {
panel.above() *requires* a panel object in the first place which
may be undesirable. */
static PyObject *
PyCurses_bottom_panel(PyObject *self, PyObject *args)
PyCurses_bottom_panel(PyObject *self)
{
PANEL *pan;
PyCursesPanelObject *po;
PyCursesInitialised;
if (!PyArg_NoArgs(args)) return NULL;
pan = panel_above(NULL);
@ -403,14 +401,12 @@ PyCurses_new_panel(PyObject *self, PyObject *args)
*requires* a panel object in the first place which may be
undesirable. */
static PyObject *
PyCurses_top_panel(PyObject *self, PyObject *args)
PyCurses_top_panel(PyObject *self)
{
PANEL *pan;
PyCursesPanelObject *po;
PyCursesInitialised;
if (!PyArg_NoArgs(args)) return NULL;
pan = panel_below(NULL);
@ -429,10 +425,9 @@ PyCurses_top_panel(PyObject *self, PyObject *args)
return (PyObject *)po;
}
static PyObject *PyCurses_update_panels(PyObject *self, PyObject *args)
static PyObject *PyCurses_update_panels(PyObject *self)
{
PyCursesInitialised;
if (!PyArg_NoArgs(args)) return NULL;
update_panels();
Py_INCREF(Py_None);
return Py_None;
@ -442,10 +437,10 @@ static PyObject *PyCurses_update_panels(PyObject *self, PyObject *args)
/* List of functions defined in the module */
static PyMethodDef PyCurses_methods[] = {
{"bottom_panel", (PyCFunction)PyCurses_bottom_panel},
{"new_panel", (PyCFunction)PyCurses_new_panel, METH_VARARGS},
{"top_panel", (PyCFunction)PyCurses_top_panel},
{"update_panels", (PyCFunction)PyCurses_update_panels},
{"bottom_panel", (PyCFunction)PyCurses_bottom_panel, METH_NOARGS},
{"new_panel", (PyCFunction)PyCurses_new_panel, METH_VARARGS},
{"top_panel", (PyCFunction)PyCurses_top_panel, METH_NOARGS},
{"update_panels", (PyCFunction)PyCurses_update_panels, METH_NOARGS},
{NULL, NULL} /* sentinel */
};

View File

@ -245,15 +245,12 @@ static char localeconv__doc__[] =
;
static PyObject*
PyLocale_localeconv(PyObject* self, PyObject* args)
PyLocale_localeconv(PyObject* self)
{
PyObject* result;
struct lconv *l;
PyObject *x;
if (!PyArg_NoArgs(args))
return NULL;
result = PyDict_New();
if (!result)
return NULL;
@ -368,14 +365,11 @@ PyLocale_strxfrm(PyObject* self, PyObject* args)
#if defined(MS_WIN32)
static PyObject*
PyLocale_getdefaultlocale(PyObject* self, PyObject* args)
PyLocale_getdefaultlocale(PyObject* self)
{
char encoding[100];
char locale[100];
if (!PyArg_NoArgs(args))
return NULL;
PyOS_snprintf(encoding, sizeof(encoding), "cp%d", GetACP());
if (GetLocaleInfo(LOCALE_USER_DEFAULT,
@ -408,7 +402,7 @@ PyLocale_getdefaultlocale(PyObject* self, PyObject* args)
#if defined(macintosh)
static PyObject*
PyLocale_getdefaultlocale(PyObject* self, PyObject* args)
PyLocale_getdefaultlocale(PyObject* self)
{
return Py_BuildValue("Os", Py_None, PyMac_getscript());
}
@ -530,13 +524,13 @@ static struct PyMethodDef PyLocale_Methods[] = {
{"setlocale", (PyCFunction) PyLocale_setlocale,
METH_VARARGS, setlocale__doc__},
{"localeconv", (PyCFunction) PyLocale_localeconv,
0, localeconv__doc__},
METH_NOARGS, localeconv__doc__},
{"strcoll", (PyCFunction) PyLocale_strcoll,
METH_VARARGS, strcoll__doc__},
{"strxfrm", (PyCFunction) PyLocale_strxfrm,
METH_VARARGS, strxfrm__doc__},
#if defined(MS_WIN32) || defined(macintosh)
{"_getdefaultlocale", (PyCFunction) PyLocale_getdefaultlocale, 0},
{"_getdefaultlocale", (PyCFunction) PyLocale_getdefaultlocale, METH_NOARGS},
#endif
#ifdef HAVE_LANGINFO_H
{"nl_langinfo", (PyCFunction) PyLocale_nl_langinfo,

View File

@ -380,10 +380,8 @@ static PyMappingMethods bsddb_as_mapping = {
};
static PyObject *
bsddb_close(bsddbobject *dp, PyObject *args)
bsddb_close(bsddbobject *dp)
{
if (!PyArg_NoArgs(args))
return NULL;
if (dp->di_bsddb != NULL) {
int status;
BSDDB_BGN_SAVE(dp)
@ -401,7 +399,7 @@ bsddb_close(bsddbobject *dp, PyObject *args)
}
static PyObject *
bsddb_keys(bsddbobject *dp, PyObject *args)
bsddb_keys(bsddbobject *dp)
{
PyObject *list, *item=NULL;
DBT krec, drec;
@ -409,8 +407,6 @@ bsddb_keys(bsddbobject *dp, PyObject *args)
int status;
int err;
if (!PyArg_NoArgs(args))
return NULL;
check_bsddbobject_open(dp, NULL);
list = PyList_New(0);
if (list == NULL)
@ -562,7 +558,7 @@ bsddb_set_location(bsddbobject *dp, PyObject *key)
}
static PyObject *
bsddb_seq(bsddbobject *dp, PyObject *args, int sequence_request)
bsddb_seq(bsddbobject *dp, int sequence_request)
{
int status;
DBT krec, drec;
@ -570,9 +566,6 @@ bsddb_seq(bsddbobject *dp, PyObject *args, int sequence_request)
char *ddata=NULL,dbuf[4096];
PyObject *result;
if (!PyArg_NoArgs(args))
return NULL;
check_bsddbobject_open(dp, NULL);
krec.data = 0;
krec.size = 0;
@ -598,11 +591,10 @@ bsddb_seq(bsddbobject *dp, PyObject *args, int sequence_request)
if (status < 0)
PyErr_SetFromErrno(BsddbError);
else
PyErr_SetObject(PyExc_KeyError, args);
PyErr_SetString(PyExc_KeyError, "no key/data pairs");
return NULL;
}
if (dp->di_type == DB_RECNO)
result = Py_BuildValue("is#", *((int*)kdata),
ddata, drec.size);
@ -615,32 +607,30 @@ bsddb_seq(bsddbobject *dp, PyObject *args, int sequence_request)
}
static PyObject *
bsddb_next(bsddbobject *dp, PyObject *key)
bsddb_next(bsddbobject *dp)
{
return bsddb_seq(dp, key, R_NEXT);
return bsddb_seq(dp, R_NEXT);
}
static PyObject *
bsddb_previous(bsddbobject *dp, PyObject *key)
bsddb_previous(bsddbobject *dp)
{
return bsddb_seq(dp, key, R_PREV);
return bsddb_seq(dp, R_PREV);
}
static PyObject *
bsddb_first(bsddbobject *dp, PyObject *key)
bsddb_first(bsddbobject *dp)
{
return bsddb_seq(dp, key, R_FIRST);
return bsddb_seq(dp, R_FIRST);
}
static PyObject *
bsddb_last(bsddbobject *dp, PyObject *key)
bsddb_last(bsddbobject *dp)
{
return bsddb_seq(dp, key, R_LAST);
return bsddb_seq(dp, R_LAST);
}
static PyObject *
bsddb_sync(bsddbobject *dp, PyObject *args)
bsddb_sync(bsddbobject *dp)
{
int status;
if (!PyArg_NoArgs(args))
return NULL;
check_bsddbobject_open(dp, NULL);
BSDDB_BGN_SAVE(dp)
status = (dp->di_bsddb->sync)(dp->di_bsddb, 0);
@ -652,15 +642,15 @@ bsddb_sync(bsddbobject *dp, PyObject *args)
return PyInt_FromLong(status = 0);
}
static PyMethodDef bsddb_methods[] = {
{"close", (PyCFunction)bsddb_close, METH_OLDARGS},
{"keys", (PyCFunction)bsddb_keys, METH_OLDARGS},
{"close", (PyCFunction)bsddb_close, METH_NOARGS},
{"keys", (PyCFunction)bsddb_keys, METH_NOARGS},
{"has_key", (PyCFunction)bsddb_has_key, METH_OLDARGS},
{"set_location", (PyCFunction)bsddb_set_location, METH_OLDARGS},
{"next", (PyCFunction)bsddb_next, METH_OLDARGS},
{"previous", (PyCFunction)bsddb_previous, METH_OLDARGS},
{"first", (PyCFunction)bsddb_first, METH_OLDARGS},
{"last", (PyCFunction)bsddb_last, METH_OLDARGS},
{"sync", (PyCFunction)bsddb_sync, METH_OLDARGS},
{"next", (PyCFunction)bsddb_next, METH_NOARGS},
{"previous", (PyCFunction)bsddb_previous, METH_NOARGS},
{"first", (PyCFunction)bsddb_first, METH_NOARGS},
{"last", (PyCFunction)bsddb_last, METH_NOARGS},
{"sync", (PyCFunction)bsddb_sync, METH_NOARGS},
{NULL, NULL} /* sentinel */
};

View File

@ -70,14 +70,11 @@ arguments.";
static PyObject *
md5_digest(md5object *self, PyObject *args)
md5_digest(md5object *self)
{
MD5_CTX mdContext;
unsigned char aDigest[16];
if (!PyArg_NoArgs(args))
return NULL;
/* make a temporary copy, and perform the final */
mdContext = self->md5;
MD5Final(aDigest, &mdContext);
@ -94,16 +91,13 @@ including null bytes.";
static PyObject *
md5_hexdigest(md5object *self, PyObject *args)
md5_hexdigest(md5object *self)
{
MD5_CTX mdContext;
unsigned char digest[16];
unsigned char hexdigest[32];
int i, j;
if (!PyArg_NoArgs(args))
return NULL;
/* make a temporary copy, and perform the final */
mdContext = self->md5;
MD5Final(digest, &mdContext);
@ -129,13 +123,10 @@ Like digest(), but returns the digest as a string of hexadecimal digits.";
static PyObject *
md5_copy(md5object *self, PyObject *args)
md5_copy(md5object *self)
{
md5object *md5p;
if (!PyArg_NoArgs(args))
return NULL;
if ((md5p = newmd5object()) == NULL)
return NULL;
@ -152,9 +143,9 @@ Return a copy (``clone'') of the md5 object.";
static PyMethodDef md5_methods[] = {
{"update", (PyCFunction)md5_update, METH_OLDARGS, update_doc},
{"digest", (PyCFunction)md5_digest, METH_OLDARGS, digest_doc},
{"hexdigest", (PyCFunction)md5_hexdigest, METH_OLDARGS, hexdigest_doc},
{"copy", (PyCFunction)md5_copy, METH_OLDARGS, copy_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},
{NULL, NULL} /* sentinel */
};

View File

@ -120,12 +120,10 @@ in arbitrary order.\n\
See pwd.__doc__ for more on password database entries.";
static PyObject *
pwd_getpwall(PyObject *self, PyObject *args)
pwd_getpwall(PyObject *self)
{
PyObject *d;
struct passwd *p;
if (!PyArg_NoArgs(args))
return NULL;
if ((d = PyList_New(0)) == NULL)
return NULL;
#if defined(PYOS_OS2) && defined(PYCC_GCC)
@ -151,7 +149,7 @@ static PyMethodDef pwd_methods[] = {
{"getpwuid", pwd_getpwuid, METH_OLDARGS, pwd_getpwuid__doc__},
{"getpwnam", pwd_getpwnam, METH_OLDARGS, pwd_getpwnam__doc__},
#ifdef HAVE_GETPWENT
{"getpwall", pwd_getpwall, METH_OLDARGS, pwd_getpwall__doc__},
{"getpwall", pwd_getpwall, METH_NOARGS, pwd_getpwall__doc__},
#endif
{NULL, NULL} /* sentinel */
};

View File

@ -237,11 +237,8 @@ static PyObject *endidx = NULL;
/* get the beginning index for the scope of the tab-completion */
static PyObject *
get_begidx(PyObject *self, PyObject *args)
get_begidx(PyObject *self)
{
if(!PyArg_NoArgs(args)) {
return NULL;
}
Py_INCREF(begidx);
return begidx;
}
@ -252,11 +249,8 @@ get the beginning index of the readline tab-completion scope";
/* get the ending index for the scope of the tab-completion */
static PyObject *
get_endidx(PyObject *self, PyObject *args)
get_endidx(PyObject *self)
{
if(!PyArg_NoArgs(args)) {
return NULL;
}
Py_INCREF(endidx);
return endidx;
}
@ -307,11 +301,8 @@ add a line to the history buffer";
/* get the tab-completion word-delimiters that readline uses */
static PyObject *
get_completer_delims(PyObject *self, PyObject *args)
get_completer_delims(PyObject *self)
{
if(!PyArg_NoArgs(args)) {
return NULL;
}
return PyString_FromString(rl_completer_word_break_characters);
}
@ -359,12 +350,10 @@ return the current contents of history item at index.\
/* Exported function to get current length of history */
static PyObject *
get_current_history_length(PyObject *self, PyObject *args)
get_current_history_length(PyObject *self)
{
HISTORY_STATE *hist_st;
if (!PyArg_NoArgs(args))
return NULL;
hist_st = history_get_history_state();
return PyInt_FromLong(hist_st ? (long) hist_st->length : (long) 0);
}
@ -377,10 +366,8 @@ return the current (not the maximum) length of history.\
/* Exported function to read the current line buffer */
static PyObject *
get_line_buffer(PyObject *self, PyObject *args)
get_line_buffer(PyObject *self)
{
if (!PyArg_NoArgs(args))
return NULL;
return PyString_FromString(rl_line_buffer);
}
@ -427,7 +414,7 @@ static struct PyMethodDef readline_methods[] =
{
{"parse_and_bind", parse_and_bind, METH_VARARGS, doc_parse_and_bind},
{"get_line_buffer", get_line_buffer,
METH_OLDARGS, doc_get_line_buffer},
METH_NOARGS, doc_get_line_buffer},
{"insert_text", insert_text, METH_VARARGS, doc_insert_text},
{"redisplay", (PyCFunction)redisplay, METH_NOARGS, doc_redisplay},
{"read_init_file", read_init_file, METH_VARARGS, doc_read_init_file},
@ -438,20 +425,20 @@ static struct PyMethodDef readline_methods[] =
{"get_history_item", get_history_item,
METH_VARARGS, doc_get_history_item},
{"get_current_history_length", get_current_history_length,
METH_OLDARGS, doc_get_current_history_length},
METH_NOARGS, doc_get_current_history_length},
{"set_history_length", set_history_length,
METH_VARARGS, set_history_length_doc},
{"get_history_length", get_history_length,
METH_VARARGS, get_history_length_doc},
{"set_completer", set_completer, METH_VARARGS, doc_set_completer},
{"get_begidx", get_begidx, METH_OLDARGS, doc_get_begidx},
{"get_endidx", get_endidx, METH_OLDARGS, doc_get_endidx},
{"get_begidx", get_begidx, METH_NOARGS, doc_get_begidx},
{"get_endidx", get_endidx, METH_NOARGS, doc_get_endidx},
{"set_completer_delims", set_completer_delims,
METH_VARARGS, doc_set_completer_delims},
{"add_history", py_add_history, METH_VARARGS, doc_add_history},
{"get_completer_delims", get_completer_delims,
METH_OLDARGS, doc_get_completer_delims},
METH_NOARGS, doc_get_completer_delims},
{"set_startup_hook", set_startup_hook, METH_VARARGS, doc_set_startup_hook},
#ifdef HAVE_RL_PRE_INPUT_HOOK

View File

@ -163,11 +163,8 @@ Arrange for SIGALRM to arrive after the given number of seconds.";
#ifdef HAVE_PAUSE
static PyObject *
signal_pause(PyObject *self, PyObject *args)
signal_pause(PyObject *self)
{
if (!PyArg_NoArgs(args))
return NULL;
Py_BEGIN_ALLOW_THREADS
(void)pause();
Py_END_ALLOW_THREADS
@ -282,7 +279,7 @@ static PyMethodDef signal_methods[] = {
{"signal", signal_signal, METH_OLDARGS, signal_doc},
{"getsignal", signal_getsignal, METH_OLDARGS, getsignal_doc},
#ifdef HAVE_PAUSE
{"pause", signal_pause, METH_OLDARGS, pause_doc},
{"pause", signal_pause, METH_NOARGS, pause_doc},
#endif
{"default_int_handler", signal_default_int_handler,
METH_OLDARGS, default_int_handler_doc},

View File

@ -87,11 +87,8 @@ and the return value reflects whether the lock is acquired.\n\
The blocking operation is not interruptible.";
static PyObject *
lock_PyThread_release_lock(lockobject *self, PyObject *args)
lock_PyThread_release_lock(lockobject *self)
{
if (!PyArg_NoArgs(args))
return NULL;
/* Sanity check: the lock must be locked */
if (PyThread_acquire_lock(self->lock_lock, 0)) {
PyThread_release_lock(self->lock_lock);
@ -113,11 +110,8 @@ the lock to acquire the lock. The lock must be in the locked state,\n\
but it needn't be locked by the same thread that unlocks it.";
static PyObject *
lock_locked_lock(lockobject *self, PyObject *args)
lock_locked_lock(lockobject *self)
{
if (!PyArg_NoArgs(args))
return NULL;
if (PyThread_acquire_lock(self->lock_lock, 0)) {
PyThread_release_lock(self->lock_lock);
return PyInt_FromLong(0L);
@ -137,11 +131,11 @@ static PyMethodDef lock_methods[] = {
{"acquire", (PyCFunction)lock_PyThread_acquire_lock,
METH_OLDARGS, acquire_doc},
{"release_lock", (PyCFunction)lock_PyThread_release_lock,
METH_OLDARGS, release_doc},
METH_NOARGS, release_doc},
{"release", (PyCFunction)lock_PyThread_release_lock,
METH_OLDARGS, release_doc},
{"locked_lock", (PyCFunction)lock_locked_lock,
METH_OLDARGS, locked_doc},
METH_NOARGS, locked_doc},
{"locked", (PyCFunction)lock_locked_lock,
METH_OLDARGS, locked_doc},
{NULL, NULL} /* sentinel */
@ -267,10 +261,8 @@ when the function raises an unhandled exception; a stack trace will be\n\
printed unless the exception is SystemExit.\n";
static PyObject *
thread_PyThread_exit_thread(PyObject *self, PyObject *args)
thread_PyThread_exit_thread(PyObject *self)
{
if (!PyArg_NoArgs(args))
return NULL;
PyErr_SetNone(PyExc_SystemExit);
return NULL;
}
@ -295,10 +287,8 @@ thread_PyThread_exit_prog(PyObject *self, PyObject *args)
#endif
static PyObject *
thread_PyThread_allocate_lock(PyObject *self, PyObject *args)
thread_PyThread_allocate_lock(PyObject *self)
{
if (!PyArg_NoArgs(args))
return NULL;
return (PyObject *) newlockobject();
}
@ -309,11 +299,9 @@ static char allocate_doc[] =
Create a new lock object. See LockType.__doc__ for information about locks.";
static PyObject *
thread_get_ident(PyObject *self, PyObject *args)
thread_get_ident(PyObject *self)
{
long ident;
if (!PyArg_NoArgs(args))
return NULL;
ident = PyThread_get_thread_ident();
if (ident == -1) {
PyErr_SetString(ThreadError, "no current thread ident");
@ -341,15 +329,15 @@ static PyMethodDef thread_methods[] = {
METH_VARARGS,
start_new_doc},
{"allocate_lock", (PyCFunction)thread_PyThread_allocate_lock,
METH_OLDARGS, allocate_doc},
METH_NOARGS, allocate_doc},
{"allocate", (PyCFunction)thread_PyThread_allocate_lock,
METH_OLDARGS, allocate_doc},
{"exit_thread", (PyCFunction)thread_PyThread_exit_thread,
METH_OLDARGS, exit_doc},
METH_NOARGS, exit_doc},
{"exit", (PyCFunction)thread_PyThread_exit_thread,
METH_OLDARGS, exit_doc},
{"get_ident", (PyCFunction)thread_get_ident,
METH_OLDARGS, get_ident_doc},
METH_NOARGS, get_ident_doc},
#ifndef NO_EXIT_PROG
{"exit_prog", (PyCFunction)thread_PyThread_exit_prog},
#endif