mirror of
https://github.com/python/cpython.git
synced 2025-12-04 16:43:27 +00:00
Remove many uses of PyArg_NoArgs macro, change METH_OLDARGS to METH_NOARGS.
This commit is contained in:
parent
57f8e06e4f
commit
3a6f97850b
9 changed files with 65 additions and 122 deletions
|
|
@ -118,6 +118,9 @@
|
||||||
#include "abstract.h"
|
#include "abstract.h"
|
||||||
|
|
||||||
#define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a))
|
#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, "")
|
#define PyArg_NoArgs(v) PyArg_Parse(v, "")
|
||||||
|
|
||||||
/* Convert a possibly signed character to a nonnegative int */
|
/* Convert a possibly signed character to a nonnegative int */
|
||||||
|
|
|
||||||
|
|
@ -355,15 +355,13 @@ PyTypeObject PyCursesPanel_Type = {
|
||||||
panel.above() *requires* a panel object in the first place which
|
panel.above() *requires* a panel object in the first place which
|
||||||
may be undesirable. */
|
may be undesirable. */
|
||||||
static PyObject *
|
static PyObject *
|
||||||
PyCurses_bottom_panel(PyObject *self, PyObject *args)
|
PyCurses_bottom_panel(PyObject *self)
|
||||||
{
|
{
|
||||||
PANEL *pan;
|
PANEL *pan;
|
||||||
PyCursesPanelObject *po;
|
PyCursesPanelObject *po;
|
||||||
|
|
||||||
PyCursesInitialised;
|
PyCursesInitialised;
|
||||||
|
|
||||||
if (!PyArg_NoArgs(args)) return NULL;
|
|
||||||
|
|
||||||
pan = panel_above(NULL);
|
pan = panel_above(NULL);
|
||||||
|
|
||||||
if (pan == NULL) { /* valid output, it means
|
if (pan == NULL) { /* valid output, it means
|
||||||
|
|
@ -403,15 +401,13 @@ PyCurses_new_panel(PyObject *self, PyObject *args)
|
||||||
*requires* a panel object in the first place which may be
|
*requires* a panel object in the first place which may be
|
||||||
undesirable. */
|
undesirable. */
|
||||||
static PyObject *
|
static PyObject *
|
||||||
PyCurses_top_panel(PyObject *self, PyObject *args)
|
PyCurses_top_panel(PyObject *self)
|
||||||
{
|
{
|
||||||
PANEL *pan;
|
PANEL *pan;
|
||||||
PyCursesPanelObject *po;
|
PyCursesPanelObject *po;
|
||||||
|
|
||||||
PyCursesInitialised;
|
PyCursesInitialised;
|
||||||
|
|
||||||
if (!PyArg_NoArgs(args)) return NULL;
|
|
||||||
|
|
||||||
pan = panel_below(NULL);
|
pan = panel_below(NULL);
|
||||||
|
|
||||||
if (pan == NULL) { /* valid output, it means
|
if (pan == NULL) { /* valid output, it means
|
||||||
|
|
@ -429,10 +425,9 @@ PyCurses_top_panel(PyObject *self, PyObject *args)
|
||||||
return (PyObject *)po;
|
return (PyObject *)po;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *PyCurses_update_panels(PyObject *self, PyObject *args)
|
static PyObject *PyCurses_update_panels(PyObject *self)
|
||||||
{
|
{
|
||||||
PyCursesInitialised;
|
PyCursesInitialised;
|
||||||
if (!PyArg_NoArgs(args)) return NULL;
|
|
||||||
update_panels();
|
update_panels();
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return 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 */
|
/* List of functions defined in the module */
|
||||||
|
|
||||||
static PyMethodDef PyCurses_methods[] = {
|
static PyMethodDef PyCurses_methods[] = {
|
||||||
{"bottom_panel", (PyCFunction)PyCurses_bottom_panel},
|
{"bottom_panel", (PyCFunction)PyCurses_bottom_panel, METH_NOARGS},
|
||||||
{"new_panel", (PyCFunction)PyCurses_new_panel, METH_VARARGS},
|
{"new_panel", (PyCFunction)PyCurses_new_panel, METH_VARARGS},
|
||||||
{"top_panel", (PyCFunction)PyCurses_top_panel},
|
{"top_panel", (PyCFunction)PyCurses_top_panel, METH_NOARGS},
|
||||||
{"update_panels", (PyCFunction)PyCurses_update_panels},
|
{"update_panels", (PyCFunction)PyCurses_update_panels, METH_NOARGS},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -245,15 +245,12 @@ static char localeconv__doc__[] =
|
||||||
;
|
;
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
PyLocale_localeconv(PyObject* self, PyObject* args)
|
PyLocale_localeconv(PyObject* self)
|
||||||
{
|
{
|
||||||
PyObject* result;
|
PyObject* result;
|
||||||
struct lconv *l;
|
struct lconv *l;
|
||||||
PyObject *x;
|
PyObject *x;
|
||||||
|
|
||||||
if (!PyArg_NoArgs(args))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
result = PyDict_New();
|
result = PyDict_New();
|
||||||
if (!result)
|
if (!result)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -368,14 +365,11 @@ PyLocale_strxfrm(PyObject* self, PyObject* args)
|
||||||
|
|
||||||
#if defined(MS_WIN32)
|
#if defined(MS_WIN32)
|
||||||
static PyObject*
|
static PyObject*
|
||||||
PyLocale_getdefaultlocale(PyObject* self, PyObject* args)
|
PyLocale_getdefaultlocale(PyObject* self)
|
||||||
{
|
{
|
||||||
char encoding[100];
|
char encoding[100];
|
||||||
char locale[100];
|
char locale[100];
|
||||||
|
|
||||||
if (!PyArg_NoArgs(args))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
PyOS_snprintf(encoding, sizeof(encoding), "cp%d", GetACP());
|
PyOS_snprintf(encoding, sizeof(encoding), "cp%d", GetACP());
|
||||||
|
|
||||||
if (GetLocaleInfo(LOCALE_USER_DEFAULT,
|
if (GetLocaleInfo(LOCALE_USER_DEFAULT,
|
||||||
|
|
@ -408,7 +402,7 @@ PyLocale_getdefaultlocale(PyObject* self, PyObject* args)
|
||||||
|
|
||||||
#if defined(macintosh)
|
#if defined(macintosh)
|
||||||
static PyObject*
|
static PyObject*
|
||||||
PyLocale_getdefaultlocale(PyObject* self, PyObject* args)
|
PyLocale_getdefaultlocale(PyObject* self)
|
||||||
{
|
{
|
||||||
return Py_BuildValue("Os", Py_None, PyMac_getscript());
|
return Py_BuildValue("Os", Py_None, PyMac_getscript());
|
||||||
}
|
}
|
||||||
|
|
@ -530,13 +524,13 @@ static struct PyMethodDef PyLocale_Methods[] = {
|
||||||
{"setlocale", (PyCFunction) PyLocale_setlocale,
|
{"setlocale", (PyCFunction) PyLocale_setlocale,
|
||||||
METH_VARARGS, setlocale__doc__},
|
METH_VARARGS, setlocale__doc__},
|
||||||
{"localeconv", (PyCFunction) PyLocale_localeconv,
|
{"localeconv", (PyCFunction) PyLocale_localeconv,
|
||||||
0, localeconv__doc__},
|
METH_NOARGS, localeconv__doc__},
|
||||||
{"strcoll", (PyCFunction) PyLocale_strcoll,
|
{"strcoll", (PyCFunction) PyLocale_strcoll,
|
||||||
METH_VARARGS, strcoll__doc__},
|
METH_VARARGS, strcoll__doc__},
|
||||||
{"strxfrm", (PyCFunction) PyLocale_strxfrm,
|
{"strxfrm", (PyCFunction) PyLocale_strxfrm,
|
||||||
METH_VARARGS, strxfrm__doc__},
|
METH_VARARGS, strxfrm__doc__},
|
||||||
#if defined(MS_WIN32) || defined(macintosh)
|
#if defined(MS_WIN32) || defined(macintosh)
|
||||||
{"_getdefaultlocale", (PyCFunction) PyLocale_getdefaultlocale, 0},
|
{"_getdefaultlocale", (PyCFunction) PyLocale_getdefaultlocale, METH_NOARGS},
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_LANGINFO_H
|
#ifdef HAVE_LANGINFO_H
|
||||||
{"nl_langinfo", (PyCFunction) PyLocale_nl_langinfo,
|
{"nl_langinfo", (PyCFunction) PyLocale_nl_langinfo,
|
||||||
|
|
|
||||||
|
|
@ -380,10 +380,8 @@ static PyMappingMethods bsddb_as_mapping = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
bsddb_close(bsddbobject *dp, PyObject *args)
|
bsddb_close(bsddbobject *dp)
|
||||||
{
|
{
|
||||||
if (!PyArg_NoArgs(args))
|
|
||||||
return NULL;
|
|
||||||
if (dp->di_bsddb != NULL) {
|
if (dp->di_bsddb != NULL) {
|
||||||
int status;
|
int status;
|
||||||
BSDDB_BGN_SAVE(dp)
|
BSDDB_BGN_SAVE(dp)
|
||||||
|
|
@ -401,7 +399,7 @@ bsddb_close(bsddbobject *dp, PyObject *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
bsddb_keys(bsddbobject *dp, PyObject *args)
|
bsddb_keys(bsddbobject *dp)
|
||||||
{
|
{
|
||||||
PyObject *list, *item=NULL;
|
PyObject *list, *item=NULL;
|
||||||
DBT krec, drec;
|
DBT krec, drec;
|
||||||
|
|
@ -409,8 +407,6 @@ bsddb_keys(bsddbobject *dp, PyObject *args)
|
||||||
int status;
|
int status;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!PyArg_NoArgs(args))
|
|
||||||
return NULL;
|
|
||||||
check_bsddbobject_open(dp, NULL);
|
check_bsddbobject_open(dp, NULL);
|
||||||
list = PyList_New(0);
|
list = PyList_New(0);
|
||||||
if (list == NULL)
|
if (list == NULL)
|
||||||
|
|
@ -562,7 +558,7 @@ bsddb_set_location(bsddbobject *dp, PyObject *key)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
bsddb_seq(bsddbobject *dp, PyObject *args, int sequence_request)
|
bsddb_seq(bsddbobject *dp, int sequence_request)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
DBT krec, drec;
|
DBT krec, drec;
|
||||||
|
|
@ -570,9 +566,6 @@ bsddb_seq(bsddbobject *dp, PyObject *args, int sequence_request)
|
||||||
char *ddata=NULL,dbuf[4096];
|
char *ddata=NULL,dbuf[4096];
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
|
|
||||||
if (!PyArg_NoArgs(args))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
check_bsddbobject_open(dp, NULL);
|
check_bsddbobject_open(dp, NULL);
|
||||||
krec.data = 0;
|
krec.data = 0;
|
||||||
krec.size = 0;
|
krec.size = 0;
|
||||||
|
|
@ -598,11 +591,10 @@ bsddb_seq(bsddbobject *dp, PyObject *args, int sequence_request)
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
PyErr_SetFromErrno(BsddbError);
|
PyErr_SetFromErrno(BsddbError);
|
||||||
else
|
else
|
||||||
PyErr_SetObject(PyExc_KeyError, args);
|
PyErr_SetString(PyExc_KeyError, "no key/data pairs");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (dp->di_type == DB_RECNO)
|
if (dp->di_type == DB_RECNO)
|
||||||
result = Py_BuildValue("is#", *((int*)kdata),
|
result = Py_BuildValue("is#", *((int*)kdata),
|
||||||
ddata, drec.size);
|
ddata, drec.size);
|
||||||
|
|
@ -615,32 +607,30 @@ bsddb_seq(bsddbobject *dp, PyObject *args, int sequence_request)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
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 *
|
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 *
|
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 *
|
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 *
|
static PyObject *
|
||||||
bsddb_sync(bsddbobject *dp, PyObject *args)
|
bsddb_sync(bsddbobject *dp)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
if (!PyArg_NoArgs(args))
|
|
||||||
return NULL;
|
|
||||||
check_bsddbobject_open(dp, NULL);
|
check_bsddbobject_open(dp, NULL);
|
||||||
BSDDB_BGN_SAVE(dp)
|
BSDDB_BGN_SAVE(dp)
|
||||||
status = (dp->di_bsddb->sync)(dp->di_bsddb, 0);
|
status = (dp->di_bsddb->sync)(dp->di_bsddb, 0);
|
||||||
|
|
@ -652,15 +642,15 @@ bsddb_sync(bsddbobject *dp, PyObject *args)
|
||||||
return PyInt_FromLong(status = 0);
|
return PyInt_FromLong(status = 0);
|
||||||
}
|
}
|
||||||
static PyMethodDef bsddb_methods[] = {
|
static PyMethodDef bsddb_methods[] = {
|
||||||
{"close", (PyCFunction)bsddb_close, METH_OLDARGS},
|
{"close", (PyCFunction)bsddb_close, METH_NOARGS},
|
||||||
{"keys", (PyCFunction)bsddb_keys, METH_OLDARGS},
|
{"keys", (PyCFunction)bsddb_keys, METH_NOARGS},
|
||||||
{"has_key", (PyCFunction)bsddb_has_key, METH_OLDARGS},
|
{"has_key", (PyCFunction)bsddb_has_key, METH_OLDARGS},
|
||||||
{"set_location", (PyCFunction)bsddb_set_location, METH_OLDARGS},
|
{"set_location", (PyCFunction)bsddb_set_location, METH_OLDARGS},
|
||||||
{"next", (PyCFunction)bsddb_next, METH_OLDARGS},
|
{"next", (PyCFunction)bsddb_next, METH_NOARGS},
|
||||||
{"previous", (PyCFunction)bsddb_previous, METH_OLDARGS},
|
{"previous", (PyCFunction)bsddb_previous, METH_NOARGS},
|
||||||
{"first", (PyCFunction)bsddb_first, METH_OLDARGS},
|
{"first", (PyCFunction)bsddb_first, METH_NOARGS},
|
||||||
{"last", (PyCFunction)bsddb_last, METH_OLDARGS},
|
{"last", (PyCFunction)bsddb_last, METH_NOARGS},
|
||||||
{"sync", (PyCFunction)bsddb_sync, METH_OLDARGS},
|
{"sync", (PyCFunction)bsddb_sync, METH_NOARGS},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,14 +70,11 @@ arguments.";
|
||||||
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
md5_digest(md5object *self, PyObject *args)
|
md5_digest(md5object *self)
|
||||||
{
|
{
|
||||||
MD5_CTX mdContext;
|
MD5_CTX mdContext;
|
||||||
unsigned char aDigest[16];
|
unsigned char aDigest[16];
|
||||||
|
|
||||||
if (!PyArg_NoArgs(args))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* make a temporary copy, and perform the final */
|
/* make a temporary copy, and perform the final */
|
||||||
mdContext = self->md5;
|
mdContext = self->md5;
|
||||||
MD5Final(aDigest, &mdContext);
|
MD5Final(aDigest, &mdContext);
|
||||||
|
|
@ -94,16 +91,13 @@ including null bytes.";
|
||||||
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
md5_hexdigest(md5object *self, PyObject *args)
|
md5_hexdigest(md5object *self)
|
||||||
{
|
{
|
||||||
MD5_CTX mdContext;
|
MD5_CTX mdContext;
|
||||||
unsigned char digest[16];
|
unsigned char digest[16];
|
||||||
unsigned char hexdigest[32];
|
unsigned char hexdigest[32];
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
if (!PyArg_NoArgs(args))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* make a temporary copy, and perform the final */
|
/* make a temporary copy, and perform the final */
|
||||||
mdContext = self->md5;
|
mdContext = self->md5;
|
||||||
MD5Final(digest, &mdContext);
|
MD5Final(digest, &mdContext);
|
||||||
|
|
@ -129,13 +123,10 @@ Like digest(), but returns the digest as a string of hexadecimal digits.";
|
||||||
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
md5_copy(md5object *self, PyObject *args)
|
md5_copy(md5object *self)
|
||||||
{
|
{
|
||||||
md5object *md5p;
|
md5object *md5p;
|
||||||
|
|
||||||
if (!PyArg_NoArgs(args))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if ((md5p = newmd5object()) == NULL)
|
if ((md5p = newmd5object()) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
@ -152,9 +143,9 @@ Return a copy (``clone'') of the md5 object.";
|
||||||
|
|
||||||
static PyMethodDef md5_methods[] = {
|
static PyMethodDef md5_methods[] = {
|
||||||
{"update", (PyCFunction)md5_update, METH_OLDARGS, update_doc},
|
{"update", (PyCFunction)md5_update, METH_OLDARGS, update_doc},
|
||||||
{"digest", (PyCFunction)md5_digest, METH_OLDARGS, digest_doc},
|
{"digest", (PyCFunction)md5_digest, METH_NOARGS, digest_doc},
|
||||||
{"hexdigest", (PyCFunction)md5_hexdigest, METH_OLDARGS, hexdigest_doc},
|
{"hexdigest", (PyCFunction)md5_hexdigest, METH_NOARGS, hexdigest_doc},
|
||||||
{"copy", (PyCFunction)md5_copy, METH_OLDARGS, copy_doc},
|
{"copy", (PyCFunction)md5_copy, METH_NOARGS, copy_doc},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,12 +120,10 @@ in arbitrary order.\n\
|
||||||
See pwd.__doc__ for more on password database entries.";
|
See pwd.__doc__ for more on password database entries.";
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
pwd_getpwall(PyObject *self, PyObject *args)
|
pwd_getpwall(PyObject *self)
|
||||||
{
|
{
|
||||||
PyObject *d;
|
PyObject *d;
|
||||||
struct passwd *p;
|
struct passwd *p;
|
||||||
if (!PyArg_NoArgs(args))
|
|
||||||
return NULL;
|
|
||||||
if ((d = PyList_New(0)) == NULL)
|
if ((d = PyList_New(0)) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
#if defined(PYOS_OS2) && defined(PYCC_GCC)
|
#if defined(PYOS_OS2) && defined(PYCC_GCC)
|
||||||
|
|
@ -151,7 +149,7 @@ static PyMethodDef pwd_methods[] = {
|
||||||
{"getpwuid", pwd_getpwuid, METH_OLDARGS, pwd_getpwuid__doc__},
|
{"getpwuid", pwd_getpwuid, METH_OLDARGS, pwd_getpwuid__doc__},
|
||||||
{"getpwnam", pwd_getpwnam, METH_OLDARGS, pwd_getpwnam__doc__},
|
{"getpwnam", pwd_getpwnam, METH_OLDARGS, pwd_getpwnam__doc__},
|
||||||
#ifdef HAVE_GETPWENT
|
#ifdef HAVE_GETPWENT
|
||||||
{"getpwall", pwd_getpwall, METH_OLDARGS, pwd_getpwall__doc__},
|
{"getpwall", pwd_getpwall, METH_NOARGS, pwd_getpwall__doc__},
|
||||||
#endif
|
#endif
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -237,11 +237,8 @@ static PyObject *endidx = NULL;
|
||||||
|
|
||||||
/* get the beginning index for the scope of the tab-completion */
|
/* get the beginning index for the scope of the tab-completion */
|
||||||
static PyObject *
|
static PyObject *
|
||||||
get_begidx(PyObject *self, PyObject *args)
|
get_begidx(PyObject *self)
|
||||||
{
|
{
|
||||||
if(!PyArg_NoArgs(args)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
Py_INCREF(begidx);
|
Py_INCREF(begidx);
|
||||||
return 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 */
|
/* get the ending index for the scope of the tab-completion */
|
||||||
static PyObject *
|
static PyObject *
|
||||||
get_endidx(PyObject *self, PyObject *args)
|
get_endidx(PyObject *self)
|
||||||
{
|
{
|
||||||
if(!PyArg_NoArgs(args)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
Py_INCREF(endidx);
|
Py_INCREF(endidx);
|
||||||
return endidx;
|
return endidx;
|
||||||
}
|
}
|
||||||
|
|
@ -307,11 +301,8 @@ add a line to the history buffer";
|
||||||
/* get the tab-completion word-delimiters that readline uses */
|
/* get the tab-completion word-delimiters that readline uses */
|
||||||
|
|
||||||
static PyObject *
|
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);
|
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 */
|
/* Exported function to get current length of history */
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
get_current_history_length(PyObject *self, PyObject *args)
|
get_current_history_length(PyObject *self)
|
||||||
{
|
{
|
||||||
HISTORY_STATE *hist_st;
|
HISTORY_STATE *hist_st;
|
||||||
|
|
||||||
if (!PyArg_NoArgs(args))
|
|
||||||
return NULL;
|
|
||||||
hist_st = history_get_history_state();
|
hist_st = history_get_history_state();
|
||||||
return PyInt_FromLong(hist_st ? (long) hist_st->length : (long) 0);
|
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 */
|
/* Exported function to read the current line buffer */
|
||||||
|
|
||||||
static PyObject *
|
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);
|
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},
|
{"parse_and_bind", parse_and_bind, METH_VARARGS, doc_parse_and_bind},
|
||||||
{"get_line_buffer", get_line_buffer,
|
{"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},
|
{"insert_text", insert_text, METH_VARARGS, doc_insert_text},
|
||||||
{"redisplay", (PyCFunction)redisplay, METH_NOARGS, doc_redisplay},
|
{"redisplay", (PyCFunction)redisplay, METH_NOARGS, doc_redisplay},
|
||||||
{"read_init_file", read_init_file, METH_VARARGS, doc_read_init_file},
|
{"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,
|
{"get_history_item", get_history_item,
|
||||||
METH_VARARGS, doc_get_history_item},
|
METH_VARARGS, doc_get_history_item},
|
||||||
{"get_current_history_length", get_current_history_length,
|
{"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,
|
{"set_history_length", set_history_length,
|
||||||
METH_VARARGS, set_history_length_doc},
|
METH_VARARGS, set_history_length_doc},
|
||||||
{"get_history_length", get_history_length,
|
{"get_history_length", get_history_length,
|
||||||
METH_VARARGS, get_history_length_doc},
|
METH_VARARGS, get_history_length_doc},
|
||||||
{"set_completer", set_completer, METH_VARARGS, doc_set_completer},
|
{"set_completer", set_completer, METH_VARARGS, doc_set_completer},
|
||||||
{"get_begidx", get_begidx, METH_OLDARGS, doc_get_begidx},
|
{"get_begidx", get_begidx, METH_NOARGS, doc_get_begidx},
|
||||||
{"get_endidx", get_endidx, METH_OLDARGS, doc_get_endidx},
|
{"get_endidx", get_endidx, METH_NOARGS, doc_get_endidx},
|
||||||
|
|
||||||
{"set_completer_delims", set_completer_delims,
|
{"set_completer_delims", set_completer_delims,
|
||||||
METH_VARARGS, doc_set_completer_delims},
|
METH_VARARGS, doc_set_completer_delims},
|
||||||
{"add_history", py_add_history, METH_VARARGS, doc_add_history},
|
{"add_history", py_add_history, METH_VARARGS, doc_add_history},
|
||||||
{"get_completer_delims", get_completer_delims,
|
{"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},
|
{"set_startup_hook", set_startup_hook, METH_VARARGS, doc_set_startup_hook},
|
||||||
#ifdef HAVE_RL_PRE_INPUT_HOOK
|
#ifdef HAVE_RL_PRE_INPUT_HOOK
|
||||||
|
|
|
||||||
|
|
@ -163,11 +163,8 @@ Arrange for SIGALRM to arrive after the given number of seconds.";
|
||||||
|
|
||||||
#ifdef HAVE_PAUSE
|
#ifdef HAVE_PAUSE
|
||||||
static PyObject *
|
static PyObject *
|
||||||
signal_pause(PyObject *self, PyObject *args)
|
signal_pause(PyObject *self)
|
||||||
{
|
{
|
||||||
if (!PyArg_NoArgs(args))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
(void)pause();
|
(void)pause();
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
|
|
@ -282,7 +279,7 @@ static PyMethodDef signal_methods[] = {
|
||||||
{"signal", signal_signal, METH_OLDARGS, signal_doc},
|
{"signal", signal_signal, METH_OLDARGS, signal_doc},
|
||||||
{"getsignal", signal_getsignal, METH_OLDARGS, getsignal_doc},
|
{"getsignal", signal_getsignal, METH_OLDARGS, getsignal_doc},
|
||||||
#ifdef HAVE_PAUSE
|
#ifdef HAVE_PAUSE
|
||||||
{"pause", signal_pause, METH_OLDARGS, pause_doc},
|
{"pause", signal_pause, METH_NOARGS, pause_doc},
|
||||||
#endif
|
#endif
|
||||||
{"default_int_handler", signal_default_int_handler,
|
{"default_int_handler", signal_default_int_handler,
|
||||||
METH_OLDARGS, default_int_handler_doc},
|
METH_OLDARGS, default_int_handler_doc},
|
||||||
|
|
|
||||||
|
|
@ -87,11 +87,8 @@ and the return value reflects whether the lock is acquired.\n\
|
||||||
The blocking operation is not interruptible.";
|
The blocking operation is not interruptible.";
|
||||||
|
|
||||||
static PyObject *
|
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 */
|
/* Sanity check: the lock must be locked */
|
||||||
if (PyThread_acquire_lock(self->lock_lock, 0)) {
|
if (PyThread_acquire_lock(self->lock_lock, 0)) {
|
||||||
PyThread_release_lock(self->lock_lock);
|
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.";
|
but it needn't be locked by the same thread that unlocks it.";
|
||||||
|
|
||||||
static PyObject *
|
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)) {
|
if (PyThread_acquire_lock(self->lock_lock, 0)) {
|
||||||
PyThread_release_lock(self->lock_lock);
|
PyThread_release_lock(self->lock_lock);
|
||||||
return PyInt_FromLong(0L);
|
return PyInt_FromLong(0L);
|
||||||
|
|
@ -137,11 +131,11 @@ static PyMethodDef lock_methods[] = {
|
||||||
{"acquire", (PyCFunction)lock_PyThread_acquire_lock,
|
{"acquire", (PyCFunction)lock_PyThread_acquire_lock,
|
||||||
METH_OLDARGS, acquire_doc},
|
METH_OLDARGS, acquire_doc},
|
||||||
{"release_lock", (PyCFunction)lock_PyThread_release_lock,
|
{"release_lock", (PyCFunction)lock_PyThread_release_lock,
|
||||||
METH_OLDARGS, release_doc},
|
METH_NOARGS, release_doc},
|
||||||
{"release", (PyCFunction)lock_PyThread_release_lock,
|
{"release", (PyCFunction)lock_PyThread_release_lock,
|
||||||
METH_OLDARGS, release_doc},
|
METH_OLDARGS, release_doc},
|
||||||
{"locked_lock", (PyCFunction)lock_locked_lock,
|
{"locked_lock", (PyCFunction)lock_locked_lock,
|
||||||
METH_OLDARGS, locked_doc},
|
METH_NOARGS, locked_doc},
|
||||||
{"locked", (PyCFunction)lock_locked_lock,
|
{"locked", (PyCFunction)lock_locked_lock,
|
||||||
METH_OLDARGS, locked_doc},
|
METH_OLDARGS, locked_doc},
|
||||||
{NULL, NULL} /* sentinel */
|
{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";
|
printed unless the exception is SystemExit.\n";
|
||||||
|
|
||||||
static PyObject *
|
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);
|
PyErr_SetNone(PyExc_SystemExit);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -295,10 +287,8 @@ thread_PyThread_exit_prog(PyObject *self, PyObject *args)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static PyObject *
|
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();
|
return (PyObject *) newlockobject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -309,11 +299,9 @@ static char allocate_doc[] =
|
||||||
Create a new lock object. See LockType.__doc__ for information about locks.";
|
Create a new lock object. See LockType.__doc__ for information about locks.";
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
thread_get_ident(PyObject *self, PyObject *args)
|
thread_get_ident(PyObject *self)
|
||||||
{
|
{
|
||||||
long ident;
|
long ident;
|
||||||
if (!PyArg_NoArgs(args))
|
|
||||||
return NULL;
|
|
||||||
ident = PyThread_get_thread_ident();
|
ident = PyThread_get_thread_ident();
|
||||||
if (ident == -1) {
|
if (ident == -1) {
|
||||||
PyErr_SetString(ThreadError, "no current thread ident");
|
PyErr_SetString(ThreadError, "no current thread ident");
|
||||||
|
|
@ -341,15 +329,15 @@ static PyMethodDef thread_methods[] = {
|
||||||
METH_VARARGS,
|
METH_VARARGS,
|
||||||
start_new_doc},
|
start_new_doc},
|
||||||
{"allocate_lock", (PyCFunction)thread_PyThread_allocate_lock,
|
{"allocate_lock", (PyCFunction)thread_PyThread_allocate_lock,
|
||||||
METH_OLDARGS, allocate_doc},
|
METH_NOARGS, allocate_doc},
|
||||||
{"allocate", (PyCFunction)thread_PyThread_allocate_lock,
|
{"allocate", (PyCFunction)thread_PyThread_allocate_lock,
|
||||||
METH_OLDARGS, allocate_doc},
|
METH_OLDARGS, allocate_doc},
|
||||||
{"exit_thread", (PyCFunction)thread_PyThread_exit_thread,
|
{"exit_thread", (PyCFunction)thread_PyThread_exit_thread,
|
||||||
METH_OLDARGS, exit_doc},
|
METH_NOARGS, exit_doc},
|
||||||
{"exit", (PyCFunction)thread_PyThread_exit_thread,
|
{"exit", (PyCFunction)thread_PyThread_exit_thread,
|
||||||
METH_OLDARGS, exit_doc},
|
METH_OLDARGS, exit_doc},
|
||||||
{"get_ident", (PyCFunction)thread_get_ident,
|
{"get_ident", (PyCFunction)thread_get_ident,
|
||||||
METH_OLDARGS, get_ident_doc},
|
METH_NOARGS, get_ident_doc},
|
||||||
#ifndef NO_EXIT_PROG
|
#ifndef NO_EXIT_PROG
|
||||||
{"exit_prog", (PyCFunction)thread_PyThread_exit_prog},
|
{"exit_prog", (PyCFunction)thread_PyThread_exit_prog},
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue