summaryrefslogtreecommitdiff
path: root/Modules/_elementtree.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_elementtree.c')
-rw-r--r--Modules/_elementtree.c58
1 files changed, 33 insertions, 25 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 2cda98e611..2d623dc262 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -150,7 +150,7 @@ list_join(PyObject* list)
static int
is_empty_dict(PyObject *obj)
{
- return PyDict_CheckExact(obj) && PyDict_Size(obj) == 0;
+ return PyDict_CheckExact(obj) && PyDict_GET_SIZE(obj) == 0;
}
@@ -1173,8 +1173,8 @@ _elementtree_Element_find_impl(ElementObject *self, PyObject *path,
if (checkpath(path) || namespaces != Py_None) {
_Py_IDENTIFIER(find);
- return _PyObject_CallMethodId(
- st->elementpath_obj, &PyId_find, "OOO", self, path, namespaces
+ return _PyObject_CallMethodIdObjArgs(
+ st->elementpath_obj, &PyId_find, self, path, namespaces, NULL
);
}
@@ -1218,8 +1218,9 @@ _elementtree_Element_findtext_impl(ElementObject *self, PyObject *path,
elementtreestate *st = ET_STATE_GLOBAL;
if (checkpath(path) || namespaces != Py_None)
- return _PyObject_CallMethodId(
- st->elementpath_obj, &PyId_findtext, "OOOO", self, path, default_value, namespaces
+ return _PyObject_CallMethodIdObjArgs(
+ st->elementpath_obj, &PyId_findtext,
+ self, path, default_value, namespaces, NULL
);
if (!self->extra) {
@@ -1273,8 +1274,8 @@ _elementtree_Element_findall_impl(ElementObject *self, PyObject *path,
if (checkpath(tag) || namespaces != Py_None) {
_Py_IDENTIFIER(findall);
- return _PyObject_CallMethodId(
- st->elementpath_obj, &PyId_findall, "OOO", self, tag, namespaces
+ return _PyObject_CallMethodIdObjArgs(
+ st->elementpath_obj, &PyId_findall, self, tag, namespaces, NULL
);
}
@@ -1320,8 +1321,8 @@ _elementtree_Element_iterfind_impl(ElementObject *self, PyObject *path,
_Py_IDENTIFIER(iterfind);
elementtreestate *st = ET_STATE_GLOBAL;
- return _PyObject_CallMethodId(
- st->elementpath_obj, &PyId_iterfind, "OOO", self, tag, namespaces);
+ return _PyObject_CallMethodIdObjArgs(
+ st->elementpath_obj, &PyId_iterfind, self, tag, namespaces, NULL);
}
/*[clinic input]
@@ -2442,7 +2443,7 @@ treebuilder_add_subelement(PyObject *element, PyObject *child)
}
else {
PyObject *res;
- res = _PyObject_CallMethodId(element, &PyId_append, "O", child);
+ res = _PyObject_CallMethodIdObjArgs(element, &PyId_append, child, NULL);
if (res == NULL)
return -1;
Py_DECREF(res);
@@ -2497,11 +2498,13 @@ treebuilder_handle_start(TreeBuilderObject* self, PyObject* tag,
attrib = PyDict_New();
if (!attrib)
return NULL;
- node = PyObject_CallFunction(self->element_factory, "OO", tag, attrib);
+ node = PyObject_CallFunctionObjArgs(self->element_factory,
+ tag, attrib, NULL);
Py_DECREF(attrib);
}
else {
- node = PyObject_CallFunction(self->element_factory, "OO", tag, attrib);
+ node = PyObject_CallFunctionObjArgs(self->element_factory,
+ tag, attrib, NULL);
}
if (!node) {
return NULL;
@@ -2740,7 +2743,7 @@ typedef struct {
} XMLParserObject;
static PyObject*
-_elementtree_XMLParser_doctype(XMLParserObject* self, PyObject* args);
+_elementtree_XMLParser_doctype(XMLParserObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames);
static PyObject *
_elementtree_XMLParser_doctype_impl(XMLParserObject *self, PyObject *name,
PyObject *pubid, PyObject *system);
@@ -2833,7 +2836,7 @@ expat_set_error(enum XML_Error error_code, Py_ssize_t line, Py_ssize_t column,
if (errmsg == NULL)
return;
- error = PyObject_CallFunction(st->parseerror_obj, "O", errmsg);
+ error = PyObject_CallFunctionObjArgs(st->parseerror_obj, errmsg, NULL);
Py_DECREF(errmsg);
if (!error)
return;
@@ -2896,7 +2899,7 @@ expat_default_handler(XMLParserObject* self, const XML_Char* data_in,
(TreeBuilderObject*) self->target, value
);
else if (self->handle_data)
- res = PyObject_CallFunction(self->handle_data, "O", value);
+ res = PyObject_CallFunctionObjArgs(self->handle_data, value, NULL);
else
res = NULL;
Py_XDECREF(res);
@@ -2978,7 +2981,8 @@ expat_start_handler(XMLParserObject* self, const XML_Char* tag_in,
return;
}
}
- res = PyObject_CallFunction(self->handle_start, "OO", tag, attrib);
+ res = PyObject_CallFunctionObjArgs(self->handle_start,
+ tag, attrib, NULL);
} else
res = NULL;
@@ -3006,7 +3010,7 @@ expat_data_handler(XMLParserObject* self, const XML_Char* data_in,
/* shortcut */
res = treebuilder_handle_data((TreeBuilderObject*) self->target, data);
else if (self->handle_data)
- res = PyObject_CallFunction(self->handle_data, "O", data);
+ res = PyObject_CallFunctionObjArgs(self->handle_data, data, NULL);
else
res = NULL;
@@ -3033,7 +3037,7 @@ expat_end_handler(XMLParserObject* self, const XML_Char* tag_in)
else if (self->handle_end) {
tag = makeuniversal(self, tag_in);
if (tag) {
- res = PyObject_CallFunction(self->handle_end, "O", tag);
+ res = PyObject_CallFunctionObjArgs(self->handle_end, tag, NULL);
Py_DECREF(tag);
}
}
@@ -3092,7 +3096,8 @@ expat_comment_handler(XMLParserObject* self, const XML_Char* comment_in)
if (self->handle_comment) {
comment = PyUnicode_DecodeUTF8(comment_in, strlen(comment_in), "strict");
if (comment) {
- res = PyObject_CallFunction(self->handle_comment, "O", comment);
+ res = PyObject_CallFunctionObjArgs(self->handle_comment,
+ comment, NULL);
Py_XDECREF(res);
Py_DECREF(comment);
}
@@ -3143,8 +3148,9 @@ expat_start_doctype_handler(XMLParserObject *self,
/* If the target has a handler for doctype, call it. */
if (self->handle_doctype) {
- res = PyObject_CallFunction(self->handle_doctype, "OOO",
- doctype_name_obj, pubid_obj, sysid_obj);
+ res = PyObject_CallFunctionObjArgs(self->handle_doctype,
+ doctype_name_obj, pubid_obj,
+ sysid_obj, NULL);
Py_CLEAR(res);
}
else {
@@ -3163,8 +3169,9 @@ expat_start_doctype_handler(XMLParserObject *self,
if (!res)
goto clear;
Py_DECREF(res);
- res = PyObject_CallFunction(parser_doctype, "OOO",
- doctype_name_obj, pubid_obj, sysid_obj);
+ res = PyObject_CallFunctionObjArgs(parser_doctype,
+ doctype_name_obj, pubid_obj,
+ sysid_obj, NULL);
Py_CLEAR(res);
}
}
@@ -3191,7 +3198,8 @@ expat_pi_handler(XMLParserObject* self, const XML_Char* target_in,
target = PyUnicode_DecodeUTF8(target_in, strlen(target_in), "strict");
data = PyUnicode_DecodeUTF8(data_in, strlen(data_in), "strict");
if (target && data) {
- res = PyObject_CallFunction(self->handle_pi, "OO", target, data);
+ res = PyObject_CallFunctionObjArgs(self->handle_pi,
+ target, data, NULL);
Py_XDECREF(res);
Py_DECREF(data);
Py_DECREF(target);
@@ -3615,7 +3623,7 @@ _elementtree_XMLParser__setevents_impl(XMLParserObject *self,
for (i = 0; i < PySequence_Size(events_seq); ++i) {
PyObject *event_name_obj = PySequence_Fast_GET_ITEM(events_seq, i);
- char *event_name = NULL;
+ const char *event_name = NULL;
if (PyUnicode_Check(event_name_obj)) {
event_name = PyUnicode_AsUTF8(event_name_obj);
} else if (PyBytes_Check(event_name_obj)) {