summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2006-05-25 22:00:14 (GMT)
committerBrett Cannon <bcannon@gmail.com>2006-05-25 22:00:14 (GMT)
commit4c803f1c8147e21f3f5b09a522411823f3a9875e (patch)
treee30c8444f07b9a8092d6b03d2e83eb6d72cfadef /Modules
parent45c6472f999a0f80c8c4cdf52cc5145bc1184a47 (diff)
downloadcpython-4c803f1c8147e21f3f5b09a522411823f3a9875e.zip
cpython-4c803f1c8147e21f3f5b09a522411823f3a9875e.tar.gz
cpython-4c803f1c8147e21f3f5b09a522411823f3a9875e.tar.bz2
Move over to use of METH_O and METH_NOARGS.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/grpmodule.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/Modules/grpmodule.c b/Modules/grpmodule.c
index 12d33dd..e5b9f47 100644
--- a/Modules/grpmodule.c
+++ b/Modules/grpmodule.c
@@ -84,12 +84,18 @@ mkgrent(struct group *p)
}
static PyObject *
-grp_getgrgid(PyObject *self, PyObject *args)
+grp_getgrgid(PyObject *self, PyObject *pyo_id)
{
+ PyObject *py_int_id;
unsigned int gid;
struct group *p;
- if (!PyArg_ParseTuple(args, "I:getgrgid", &gid))
- return NULL;
+
+ py_int_id = PyNumber_Int(pyo_id);
+ if (!py_int_id)
+ return NULL;
+ gid = PyInt_AS_LONG(py_int_id);
+ Py_DECREF(py_int_id);
+
if ((p = getgrgid(gid)) == NULL) {
PyErr_Format(PyExc_KeyError, "getgrgid(): gid not found: %d", gid);
return NULL;
@@ -98,27 +104,33 @@ grp_getgrgid(PyObject *self, PyObject *args)
}
static PyObject *
-grp_getgrnam(PyObject *self, PyObject *args)
+grp_getgrnam(PyObject *self, PyObject *pyo_name)
{
+ PyObject *py_str_name;
char *name;
struct group *p;
- if (!PyArg_ParseTuple(args, "s:getgrnam", &name))
- return NULL;
+
+ py_str_name = PyObject_Str(pyo_name);
+ if (!py_str_name)
+ return NULL;
+ name = PyString_AS_STRING(py_str_name);
+
if ((p = getgrnam(name)) == NULL) {
PyErr_Format(PyExc_KeyError, "getgrnam(): name not found: %s", name);
+ Py_DECREF(py_str_name);
return NULL;
}
+
+ Py_DECREF(py_str_name);
return mkgrent(p);
}
static PyObject *
-grp_getgrall(PyObject *self, PyObject *args)
+grp_getgrall(PyObject *self, PyObject *ignore)
{
PyObject *d;
struct group *p;
- if (!PyArg_ParseTuple(args, ":getgrall"))
- return NULL;
if ((d = PyList_New(0)) == NULL)
return NULL;
setgrent();
@@ -136,15 +148,15 @@ grp_getgrall(PyObject *self, PyObject *args)
}
static PyMethodDef grp_methods[] = {
- {"getgrgid", grp_getgrgid, METH_VARARGS,
+ {"getgrgid", grp_getgrgid, METH_O,
"getgrgid(id) -> tuple\n\
Return the group database entry for the given numeric group ID. If\n\
id is not valid, raise KeyError."},
- {"getgrnam", grp_getgrnam, METH_VARARGS,
+ {"getgrnam", grp_getgrnam, METH_O,
"getgrnam(name) -> tuple\n\
Return the group database entry for the given group name. If\n\
name is not valid, raise KeyError."},
- {"getgrall", grp_getgrall, METH_VARARGS,
+ {"getgrall", grp_getgrall, METH_NOARGS,
"getgrall() -> list of tuples\n\
Return a list of all available group entries, in arbitrary order."},
{NULL, NULL} /* sentinel */