diff options
author | Georg Brandl <georg@python.org> | 2006-05-29 21:04:52 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-05-29 21:04:52 (GMT) |
commit | 96a8c3954cbdb186bc567a490dad8987508ce268 (patch) | |
tree | 4d6516790abcd566c43418e4c9b02e9c52cf9f2f /Modules/cjkcodecs | |
parent | fd9a4b19e9c77e9ccc3e7fcb57051cf160c0df6d (diff) | |
download | cpython-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/cjkcodecs')
-rw-r--r-- | Modules/cjkcodecs/multibytecodec.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c index 7e6aedc..7c6b989 100644 --- a/Modules/cjkcodecs/multibytecodec.c +++ b/Modules/cjkcodecs/multibytecodec.c @@ -1302,7 +1302,7 @@ mbstreamreader_read(MultibyteStreamReaderObject *self, PyObject *args) PyObject *sizeobj = NULL; Py_ssize_t size; - if (!PyArg_ParseTuple(args, "|O:read", &sizeobj)) + if (!PyArg_UnpackTuple(args, "read", 0, 1, &sizeobj)) return NULL; if (sizeobj == Py_None || sizeobj == NULL) @@ -1323,7 +1323,7 @@ mbstreamreader_readline(MultibyteStreamReaderObject *self, PyObject *args) PyObject *sizeobj = NULL; Py_ssize_t size; - if (!PyArg_ParseTuple(args, "|O:readline", &sizeobj)) + if (!PyArg_UnpackTuple(args, "readline", 0, 1, &sizeobj)) return NULL; if (sizeobj == Py_None || sizeobj == NULL) @@ -1344,7 +1344,7 @@ mbstreamreader_readlines(MultibyteStreamReaderObject *self, PyObject *args) PyObject *sizehintobj = NULL, *r, *sr; Py_ssize_t sizehint; - if (!PyArg_ParseTuple(args, "|O:readlines", &sizehintobj)) + if (!PyArg_UnpackTuple(args, "readlines", 0, 1, &sizehintobj)) return NULL; if (sizehintobj == Py_None || sizehintobj == NULL) @@ -1532,13 +1532,8 @@ mbstreamwriter_iwrite(MultibyteStreamWriterObject *self, } static PyObject * -mbstreamwriter_write(MultibyteStreamWriterObject *self, PyObject *args) +mbstreamwriter_write(MultibyteStreamWriterObject *self, PyObject *strobj) { - PyObject *strobj; - - if (!PyArg_ParseTuple(args, "O:write", &strobj)) - return NULL; - if (mbstreamwriter_iwrite(self, strobj)) return NULL; else @@ -1546,14 +1541,11 @@ mbstreamwriter_write(MultibyteStreamWriterObject *self, PyObject *args) } static PyObject * -mbstreamwriter_writelines(MultibyteStreamWriterObject *self, PyObject *args) +mbstreamwriter_writelines(MultibyteStreamWriterObject *self, PyObject *lines) { - PyObject *lines, *strobj; + PyObject *strobj; int i, r; - if (!PyArg_ParseTuple(args, "O:writelines", &lines)) - return NULL; - if (!PySequence_Check(lines)) { PyErr_SetString(PyExc_TypeError, "arg must be a sequence object"); @@ -1676,9 +1668,9 @@ mbstreamwriter_dealloc(MultibyteStreamWriterObject *self) static struct PyMethodDef mbstreamwriter_methods[] = { {"write", (PyCFunction)mbstreamwriter_write, - METH_VARARGS, NULL}, + METH_O, NULL}, {"writelines", (PyCFunction)mbstreamwriter_writelines, - METH_VARARGS, NULL}, + METH_O, NULL}, {"reset", (PyCFunction)mbstreamwriter_reset, METH_NOARGS, NULL}, {NULL, NULL}, |