summaryrefslogtreecommitdiffstats
path: root/Modules/mmapmodule.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-05-29 21:04:52 (GMT)
committerGeorg Brandl <georg@python.org>2006-05-29 21:04:52 (GMT)
commit96a8c3954cbdb186bc567a490dad8987508ce268 (patch)
tree4d6516790abcd566c43418e4c9b02e9c52cf9f2f /Modules/mmapmodule.c
parentfd9a4b19e9c77e9ccc3e7fcb57051cf160c0df6d (diff)
downloadcpython-96a8c3954cbdb186bc567a490dad8987508ce268.zip
cpython-96a8c3954cbdb186bc567a490dad8987508ce268.tar.gz
cpython-96a8c3954cbdb186bc567a490dad8987508ce268.tar.bz2
Make use of METH_O and METH_NOARGS where possible.
Use Py_UnpackTuple instead of PyArg_ParseTuple where possible.
Diffstat (limited to 'Modules/mmapmodule.c')
-rw-r--r--Modules/mmapmodule.c30
1 files changed, 10 insertions, 20 deletions
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 @@ mmap_object_dealloc(mmap_object *m_obj)
}
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 @@ do { \
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 @@ mmap_read_byte_method(mmap_object *self,
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 @@ mmap_read_line_method(mmap_object *self,
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 @@ mmap_write_byte_method(mmap_object *self,
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 @@ mmap_resize_method(mmap_object *self,
}
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 @@ mmap_move_method(mmap_object *self, PyObject *args)
}
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 */