mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
Make use of METH_O and METH_NOARGS where possible.
Use Py_UnpackTuple instead of PyArg_ParseTuple where possible.
This commit is contained in:
parent
fd9a4b19e9
commit
96a8c3954c
26 changed files with 187 additions and 405 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue