summaryrefslogtreecommitdiffstats
path: root/Modules/_elementtree.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2011-10-09 08:38:36 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2011-10-09 08:38:36 (GMT)
commitafe55bba33a20f87a58f940186359237064b428f (patch)
tree66d64a1518d79c3d0e90c0a1d0080cd88e887d99 /Modules/_elementtree.c
parent67df285a3389c7fdb8c7bd301314ac45e17f8074 (diff)
downloadcpython-afe55bba33a20f87a58f940186359237064b428f.zip
cpython-afe55bba33a20f87a58f940186359237064b428f.tar.gz
cpython-afe55bba33a20f87a58f940186359237064b428f.tar.bz2
Add API for static strings, primarily good for identifiers.
Thanks to Konrad Schöbel and Jasper Schulz for helping with the mass-editing.
Diffstat (limited to 'Modules/_elementtree.c')
-rw-r--r--Modules/_elementtree.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 0c64dd5..fcd1271 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -790,16 +790,18 @@ static PyObject*
element_find(ElementObject* self, PyObject* args)
{
int i;
-
PyObject* tag;
PyObject* namespaces = Py_None;
+
if (!PyArg_ParseTuple(args, "O|O:find", &tag, &namespaces))
return NULL;
- if (checkpath(tag) || namespaces != Py_None)
- return PyObject_CallMethod(
- elementpath_obj, "find", "OOO", self, tag, namespaces
+ if (checkpath(tag) || namespaces != Py_None) {
+ _Py_identifier(find);
+ return _PyObject_CallMethodId(
+ elementpath_obj, &PyId_find, "OOO", self, tag, namespaces
);
+ }
if (!self->extra)
Py_RETURN_NONE;
@@ -820,16 +822,17 @@ static PyObject*
element_findtext(ElementObject* self, PyObject* args)
{
int i;
-
PyObject* tag;
PyObject* default_value = Py_None;
PyObject* namespaces = Py_None;
+ _Py_identifier(findtext);
+
if (!PyArg_ParseTuple(args, "O|OO:findtext", &tag, &default_value, &namespaces))
return NULL;
if (checkpath(tag) || namespaces != Py_None)
- return PyObject_CallMethod(
- elementpath_obj, "findtext", "OOOO", self, tag, default_value, namespaces
+ return _PyObject_CallMethodId(
+ elementpath_obj, &PyId_findtext, "OOOO", self, tag, default_value, namespaces
);
if (!self->extra) {
@@ -858,16 +861,18 @@ element_findall(ElementObject* self, PyObject* args)
{
int i;
PyObject* out;
-
PyObject* tag;
PyObject* namespaces = Py_None;
+
if (!PyArg_ParseTuple(args, "O|O:findall", &tag, &namespaces))
return NULL;
- if (checkpath(tag) || namespaces != Py_None)
- return PyObject_CallMethod(
- elementpath_obj, "findall", "OOO", self, tag, namespaces
+ if (checkpath(tag) || namespaces != Py_None) {
+ _Py_identifier(findall);
+ return _PyObject_CallMethodId(
+ elementpath_obj, &PyId_findall, "OOO", self, tag, namespaces
);
+ }
out = PyList_New(0);
if (!out)
@@ -895,11 +900,13 @@ element_iterfind(ElementObject* self, PyObject* args)
{
PyObject* tag;
PyObject* namespaces = Py_None;
+ _Py_identifier(iterfind);
+
if (!PyArg_ParseTuple(args, "O|O:iterfind", &tag, &namespaces))
return NULL;
- return PyObject_CallMethod(
- elementpath_obj, "iterfind", "OOO", self, tag, namespaces
+ return _PyObject_CallMethodId(
+ elementpath_obj, &PyId_iterfind, "OOO", self, tag, namespaces
);
}