summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2013-01-05 14:26:39 (GMT)
committerEli Bendersky <eliben@gmail.com>2013-01-05 14:26:39 (GMT)
commita873690d2c027cdd1683a9b8fd013563f9b150c8 (patch)
treec849c8cd6ec034bfbcca28a5199d509db38c9062 /Modules
parent9f6a239cf1890602b752cf5acb0d010778bebc02 (diff)
downloadcpython-a873690d2c027cdd1683a9b8fd013563f9b150c8.zip
cpython-a873690d2c027cdd1683a9b8fd013563f9b150c8.tar.gz
cpython-a873690d2c027cdd1683a9b8fd013563f9b150c8.tar.bz2
The get() and iter() are now able to accept keyword arguments.
In conformance with the documentation and the Python version. Patch by Franck Michea.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_elementtree.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 0c8abcf..9f302f9 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -1031,13 +1031,16 @@ element_iterfind(ElementObject *self, PyObject *args, PyObject *kwds)
}
static PyObject*
-element_get(ElementObject* self, PyObject* args)
+element_get(ElementObject* self, PyObject* args, PyObject* kwds)
{
PyObject* value;
+ static char* kwlist[] = {"key", "default", 0};
PyObject* key;
PyObject* default_value = Py_None;
- if (!PyArg_ParseTuple(args, "O|O:get", &key, &default_value))
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:get", kwlist, &key,
+ &default_value))
return NULL;
if (!self->extra || self->extra->attrib == Py_None)
@@ -1085,10 +1088,12 @@ create_elementiter(ElementObject *self, PyObject *tag, int gettext);
static PyObject *
-element_iter(ElementObject *self, PyObject *args)
+element_iter(ElementObject *self, PyObject *args, PyObject *kwds)
{
PyObject* tag = Py_None;
- if (!PyArg_ParseTuple(args, "|O:iter", &tag))
+ static char* kwlist[] = {"tag", 0};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:iter", kwlist, &tag))
return NULL;
return create_elementiter(self, tag, 0);
@@ -1555,7 +1560,7 @@ static PyMethodDef element_methods[] = {
{"clear", (PyCFunction) element_clearmethod, METH_VARARGS},
- {"get", (PyCFunction) element_get, METH_VARARGS},
+ {"get", (PyCFunction) element_get, METH_VARARGS | METH_KEYWORDS},
{"set", (PyCFunction) element_set, METH_VARARGS},
{"find", (PyCFunction) element_find, METH_VARARGS | METH_KEYWORDS},
@@ -1567,11 +1572,11 @@ static PyMethodDef element_methods[] = {
{"insert", (PyCFunction) element_insert, METH_VARARGS},
{"remove", (PyCFunction) element_remove, METH_VARARGS},
- {"iter", (PyCFunction) element_iter, METH_VARARGS},
+ {"iter", (PyCFunction) element_iter, METH_VARARGS | METH_KEYWORDS},
{"itertext", (PyCFunction) element_itertext, METH_VARARGS},
{"iterfind", (PyCFunction) element_iterfind, METH_VARARGS | METH_KEYWORDS},
- {"getiterator", (PyCFunction) element_iter, METH_VARARGS},
+ {"getiterator", (PyCFunction) element_iter, METH_VARARGS | METH_KEYWORDS},
{"getchildren", (PyCFunction) element_getchildren, METH_VARARGS},
{"items", (PyCFunction) element_items, METH_VARARGS},
@@ -3461,7 +3466,7 @@ static PyTypeObject XMLParser_Type = {
/* python module interface */
static PyMethodDef _functions[] = {
- {"SubElement", (PyCFunction) subelement, METH_VARARGS|METH_KEYWORDS},
+ {"SubElement", (PyCFunction) subelement, METH_VARARGS | METH_KEYWORDS},
{NULL, NULL}
};