Make use of METH_O and METH_NOARGS where possible.
Use Py_UnpackTuple instead of PyArg_ParseTuple where possible.
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index 2e74e37..19970c9 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -114,10 +114,8 @@
}
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
/* For each resource we maintain, we need to check
the value is valid, and if so, free the resource
@@ -175,11 +173,9 @@
static PyObject *
mmap_read_byte_method(mmap_object *self,
- PyObject *args)
+ PyObject *unused)
{
CHECK_VALID(NULL);
- if (!PyArg_ParseTuple(args, ":read_byte"))
- return NULL;
if (self->pos < self->size) {
char value = self->data[self->pos];
self->pos += 1;
@@ -192,7 +188,7 @@
static PyObject *
mmap_read_line_method(mmap_object *self,
- PyObject *args)
+ PyObject *unused)
{
char *start = self->data+self->pos;
char *eof = self->data+self->size;
@@ -200,8 +196,6 @@
PyObject *result;
CHECK_VALID(NULL);
- if (!PyArg_ParseTuple(args, ":readline"))
- return NULL;
eol = memchr(start, '\n', self->size - self->pos);
if (!eol)
@@ -332,11 +326,9 @@
static PyObject *
mmap_size_method(mmap_object *self,
- PyObject *args)
+ PyObject *unused)
{
CHECK_VALID(NULL);
- if (!PyArg_ParseTuple(args, ":size"))
- return NULL;
#ifdef MS_WINDOWS
if (self->file_handle != INVALID_HANDLE_VALUE) {
@@ -472,11 +464,9 @@
}
static PyObject *
-mmap_tell_method(mmap_object *self, PyObject *args)
+mmap_tell_method(mmap_object *self, PyObject *unused)
{
CHECK_VALID(NULL);
- if (!PyArg_ParseTuple(args, ":tell"))
- return NULL;
return PyInt_FromLong((long) self->pos);
}
@@ -578,17 +568,17 @@
}
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},
{"flush", (PyCFunction) mmap_flush_method, METH_VARARGS},
{"move", (PyCFunction) mmap_move_method, METH_VARARGS},
{"read", (PyCFunction) mmap_read_method, METH_VARARGS},
- {"read_byte", (PyCFunction) mmap_read_byte_method, METH_VARARGS},
- {"readline", (PyCFunction) mmap_read_line_method, METH_VARARGS},
+ {"read_byte", (PyCFunction) mmap_read_byte_method, METH_NOARGS},
+ {"readline", (PyCFunction) mmap_read_line_method, METH_NOARGS},
{"resize", (PyCFunction) mmap_resize_method, METH_VARARGS},
{"seek", (PyCFunction) mmap_seek_method, METH_VARARGS},
- {"size", (PyCFunction) mmap_size_method, METH_VARARGS},
- {"tell", (PyCFunction) mmap_tell_method, METH_VARARGS},
+ {"size", (PyCFunction) mmap_size_method, METH_NOARGS},
+ {"tell", (PyCFunction) mmap_tell_method, METH_NOARGS},
{"write", (PyCFunction) mmap_write_method, METH_VARARGS},
{"write_byte", (PyCFunction) mmap_write_byte_method, METH_VARARGS},
{NULL, NULL} /* sentinel */