2015-05-04 09:32:48 -03:00
|
|
|
/*[clinic input]
|
|
|
|
preserve
|
|
|
|
[clinic start generated code]*/
|
|
|
|
|
2022-08-11 18:25:49 -03:00
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
2023-08-31 18:42:34 -03:00
|
|
|
# include "pycore_gc.h" // PyGC_Head
|
|
|
|
# include "pycore_runtime.h" // _Py_ID()
|
2022-08-11 18:25:49 -03:00
|
|
|
#endif
|
2023-08-31 18:42:34 -03:00
|
|
|
#include "pycore_abstract.h" // _PyNumber_Index()
|
2023-10-17 09:30:31 -03:00
|
|
|
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2015-05-04 09:32:48 -03:00
|
|
|
PyDoc_STRVAR(_elementtree_Element_append__doc__,
|
|
|
|
"append($self, subelement, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT_APPEND_METHODDEF \
|
2023-01-24 12:00:24 -04:00
|
|
|
{"append", _PyCFunction_CAST(_elementtree_Element_append), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_append__doc__},
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2023-01-24 12:00:24 -04:00
|
|
|
_elementtree_Element_append_impl(ElementObject *self, PyTypeObject *cls,
|
|
|
|
PyObject *subelement);
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2023-01-24 12:00:24 -04:00
|
|
|
_elementtree_Element_append(ElementObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
2015-05-04 09:32:48 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
2023-01-24 12:00:24 -04:00
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
|
|
|
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
|
|
|
|
#else
|
|
|
|
# define KWTUPLE NULL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static const char * const _keywords[] = {"", NULL};
|
|
|
|
static _PyArg_Parser _parser = {
|
|
|
|
.keywords = _keywords,
|
|
|
|
.fname = "append",
|
|
|
|
.kwtuple = KWTUPLE,
|
|
|
|
};
|
|
|
|
#undef KWTUPLE
|
|
|
|
PyObject *argsbuf[1];
|
2015-05-04 09:32:48 -03:00
|
|
|
PyObject *subelement;
|
|
|
|
|
2023-01-24 12:00:24 -04:00
|
|
|
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
|
|
|
|
if (!args) {
|
2015-05-04 09:32:48 -03:00
|
|
|
goto exit;
|
2016-06-09 10:16:06 -03:00
|
|
|
}
|
2023-01-24 12:00:24 -04:00
|
|
|
if (!PyObject_TypeCheck(args[0], clinic_state()->Element_Type)) {
|
|
|
|
_PyArg_BadArgument("append", "argument 1", (clinic_state()->Element_Type)->tp_name, args[0]);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
subelement = args[0];
|
|
|
|
return_value = _elementtree_Element_append_impl(self, cls, subelement);
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_Element_clear__doc__,
|
|
|
|
"clear($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT_CLEAR_METHODDEF \
|
|
|
|
{"clear", (PyCFunction)_elementtree_Element_clear, METH_NOARGS, _elementtree_Element_clear__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_Element_clear_impl(ElementObject *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_Element_clear(ElementObject *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
return _elementtree_Element_clear_impl(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_Element___copy____doc__,
|
|
|
|
"__copy__($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT___COPY___METHODDEF \
|
2023-01-24 12:00:24 -04:00
|
|
|
{"__copy__", _PyCFunction_CAST(_elementtree_Element___copy__), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element___copy____doc__},
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2023-01-24 12:00:24 -04:00
|
|
|
_elementtree_Element___copy___impl(ElementObject *self, PyTypeObject *cls);
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2023-01-24 12:00:24 -04:00
|
|
|
_elementtree_Element___copy__(ElementObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
2015-05-04 09:32:48 -03:00
|
|
|
{
|
2023-01-24 12:00:24 -04:00
|
|
|
if (nargs) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "__copy__() takes no arguments");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return _elementtree_Element___copy___impl(self, cls);
|
2015-05-04 09:32:48 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_Element___deepcopy____doc__,
|
|
|
|
"__deepcopy__($self, memo, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT___DEEPCOPY___METHODDEF \
|
|
|
|
{"__deepcopy__", (PyCFunction)_elementtree_Element___deepcopy__, METH_O, _elementtree_Element___deepcopy____doc__},
|
|
|
|
|
2017-09-12 11:39:15 -03:00
|
|
|
static PyObject *
|
|
|
|
_elementtree_Element___deepcopy___impl(ElementObject *self, PyObject *memo);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_Element___deepcopy__(ElementObject *self, PyObject *arg)
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
PyObject *memo;
|
|
|
|
|
2018-12-25 07:23:47 -04:00
|
|
|
if (!PyDict_Check(arg)) {
|
2019-08-29 11:49:08 -03:00
|
|
|
_PyArg_BadArgument("__deepcopy__", "argument", "dict", arg);
|
2017-09-12 11:39:15 -03:00
|
|
|
goto exit;
|
|
|
|
}
|
2018-12-25 07:23:47 -04:00
|
|
|
memo = arg;
|
2017-09-12 11:39:15 -03:00
|
|
|
return_value = _elementtree_Element___deepcopy___impl(self, memo);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
2015-05-04 09:32:48 -03:00
|
|
|
PyDoc_STRVAR(_elementtree_Element___sizeof____doc__,
|
|
|
|
"__sizeof__($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT___SIZEOF___METHODDEF \
|
|
|
|
{"__sizeof__", (PyCFunction)_elementtree_Element___sizeof__, METH_NOARGS, _elementtree_Element___sizeof____doc__},
|
|
|
|
|
2022-11-30 12:22:52 -04:00
|
|
|
static size_t
|
2015-05-04 09:32:48 -03:00
|
|
|
_elementtree_Element___sizeof___impl(ElementObject *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_Element___sizeof__(ElementObject *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
2022-11-30 12:22:52 -04:00
|
|
|
size_t _return_value;
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
_return_value = _elementtree_Element___sizeof___impl(self);
|
2022-11-30 12:22:52 -04:00
|
|
|
if ((_return_value == (size_t)-1) && PyErr_Occurred()) {
|
2015-05-04 09:32:48 -03:00
|
|
|
goto exit;
|
2016-06-09 10:16:06 -03:00
|
|
|
}
|
2022-11-30 12:22:52 -04:00
|
|
|
return_value = PyLong_FromSize_t(_return_value);
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_Element___getstate____doc__,
|
|
|
|
"__getstate__($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT___GETSTATE___METHODDEF \
|
|
|
|
{"__getstate__", (PyCFunction)_elementtree_Element___getstate__, METH_NOARGS, _elementtree_Element___getstate____doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_Element___getstate___impl(ElementObject *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_Element___getstate__(ElementObject *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
return _elementtree_Element___getstate___impl(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_Element___setstate____doc__,
|
|
|
|
"__setstate__($self, state, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT___SETSTATE___METHODDEF \
|
2023-01-24 12:00:24 -04:00
|
|
|
{"__setstate__", _PyCFunction_CAST(_elementtree_Element___setstate__), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element___setstate____doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_Element___setstate___impl(ElementObject *self,
|
|
|
|
PyTypeObject *cls, PyObject *state);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_Element___setstate__(ElementObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
|
|
|
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
|
|
|
|
#else
|
|
|
|
# define KWTUPLE NULL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static const char * const _keywords[] = {"", NULL};
|
|
|
|
static _PyArg_Parser _parser = {
|
|
|
|
.keywords = _keywords,
|
|
|
|
.fname = "__setstate__",
|
|
|
|
.kwtuple = KWTUPLE,
|
|
|
|
};
|
|
|
|
#undef KWTUPLE
|
|
|
|
PyObject *argsbuf[1];
|
|
|
|
PyObject *state;
|
|
|
|
|
|
|
|
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
|
|
|
|
if (!args) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
state = args[0];
|
|
|
|
return_value = _elementtree_Element___setstate___impl(self, cls, state);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_Element_extend__doc__,
|
|
|
|
"extend($self, elements, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT_EXTEND_METHODDEF \
|
2023-01-24 12:00:24 -04:00
|
|
|
{"extend", _PyCFunction_CAST(_elementtree_Element_extend), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_extend__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_Element_extend_impl(ElementObject *self, PyTypeObject *cls,
|
|
|
|
PyObject *elements);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_Element_extend(ElementObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
|
|
|
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
|
|
|
|
#else
|
|
|
|
# define KWTUPLE NULL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static const char * const _keywords[] = {"", NULL};
|
|
|
|
static _PyArg_Parser _parser = {
|
|
|
|
.keywords = _keywords,
|
|
|
|
.fname = "extend",
|
|
|
|
.kwtuple = KWTUPLE,
|
|
|
|
};
|
|
|
|
#undef KWTUPLE
|
|
|
|
PyObject *argsbuf[1];
|
|
|
|
PyObject *elements;
|
|
|
|
|
|
|
|
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
|
|
|
|
if (!args) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
elements = args[0];
|
|
|
|
return_value = _elementtree_Element_extend_impl(self, cls, elements);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_Element_find__doc__,
|
|
|
|
"find($self, /, path, namespaces=None)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT_FIND_METHODDEF \
|
2023-01-24 12:00:24 -04:00
|
|
|
{"find", _PyCFunction_CAST(_elementtree_Element_find), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_find__doc__},
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2023-01-24 12:00:24 -04:00
|
|
|
_elementtree_Element_find_impl(ElementObject *self, PyTypeObject *cls,
|
|
|
|
PyObject *path, PyObject *namespaces);
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2023-01-24 12:00:24 -04:00
|
|
|
_elementtree_Element_find(ElementObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
2015-05-04 09:32:48 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
2022-08-13 07:09:40 -03:00
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2022-08-13 07:09:40 -03:00
|
|
|
#define NUM_KEYWORDS 2
|
2022-08-11 18:25:49 -03:00
|
|
|
static struct {
|
|
|
|
PyGC_Head _this_is_not_used;
|
|
|
|
PyObject_VAR_HEAD
|
|
|
|
PyObject *ob_item[NUM_KEYWORDS];
|
|
|
|
} _kwtuple = {
|
|
|
|
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
|
|
|
|
.ob_item = { &_Py_ID(path), &_Py_ID(namespaces), },
|
|
|
|
};
|
|
|
|
#undef NUM_KEYWORDS
|
2022-08-13 07:09:40 -03:00
|
|
|
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
|
|
|
|
|
|
|
|
#else // !Py_BUILD_CORE
|
|
|
|
# define KWTUPLE NULL
|
|
|
|
#endif // !Py_BUILD_CORE
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2016-08-14 04:52:18 -03:00
|
|
|
static const char * const _keywords[] = {"path", "namespaces", NULL};
|
2022-08-11 18:25:49 -03:00
|
|
|
static _PyArg_Parser _parser = {
|
|
|
|
.keywords = _keywords,
|
|
|
|
.fname = "find",
|
|
|
|
.kwtuple = KWTUPLE,
|
|
|
|
};
|
|
|
|
#undef KWTUPLE
|
2019-03-14 05:32:22 -03:00
|
|
|
PyObject *argsbuf[2];
|
|
|
|
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
|
2015-05-04 09:32:48 -03:00
|
|
|
PyObject *path;
|
|
|
|
PyObject *namespaces = Py_None;
|
|
|
|
|
2019-03-14 05:32:22 -03:00
|
|
|
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
|
|
|
|
if (!args) {
|
2015-05-04 09:32:48 -03:00
|
|
|
goto exit;
|
2016-06-09 10:16:06 -03:00
|
|
|
}
|
2019-03-14 05:32:22 -03:00
|
|
|
path = args[0];
|
|
|
|
if (!noptargs) {
|
|
|
|
goto skip_optional_pos;
|
|
|
|
}
|
|
|
|
namespaces = args[1];
|
|
|
|
skip_optional_pos:
|
2023-01-24 12:00:24 -04:00
|
|
|
return_value = _elementtree_Element_find_impl(self, cls, path, namespaces);
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_Element_findtext__doc__,
|
|
|
|
"findtext($self, /, path, default=None, namespaces=None)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT_FINDTEXT_METHODDEF \
|
2023-01-24 12:00:24 -04:00
|
|
|
{"findtext", _PyCFunction_CAST(_elementtree_Element_findtext), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_findtext__doc__},
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2023-01-24 12:00:24 -04:00
|
|
|
_elementtree_Element_findtext_impl(ElementObject *self, PyTypeObject *cls,
|
|
|
|
PyObject *path, PyObject *default_value,
|
2015-05-04 09:32:48 -03:00
|
|
|
PyObject *namespaces);
|
|
|
|
|
|
|
|
static PyObject *
|
2023-01-24 12:00:24 -04:00
|
|
|
_elementtree_Element_findtext(ElementObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
2015-05-04 09:32:48 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
2022-08-13 07:09:40 -03:00
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2022-08-13 07:09:40 -03:00
|
|
|
#define NUM_KEYWORDS 3
|
2022-08-11 18:25:49 -03:00
|
|
|
static struct {
|
|
|
|
PyGC_Head _this_is_not_used;
|
|
|
|
PyObject_VAR_HEAD
|
|
|
|
PyObject *ob_item[NUM_KEYWORDS];
|
|
|
|
} _kwtuple = {
|
|
|
|
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
|
|
|
|
.ob_item = { &_Py_ID(path), &_Py_ID(default), &_Py_ID(namespaces), },
|
|
|
|
};
|
|
|
|
#undef NUM_KEYWORDS
|
2022-08-13 07:09:40 -03:00
|
|
|
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
|
|
|
|
|
|
|
|
#else // !Py_BUILD_CORE
|
|
|
|
# define KWTUPLE NULL
|
|
|
|
#endif // !Py_BUILD_CORE
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2016-08-14 04:52:18 -03:00
|
|
|
static const char * const _keywords[] = {"path", "default", "namespaces", NULL};
|
2022-08-11 18:25:49 -03:00
|
|
|
static _PyArg_Parser _parser = {
|
|
|
|
.keywords = _keywords,
|
|
|
|
.fname = "findtext",
|
|
|
|
.kwtuple = KWTUPLE,
|
|
|
|
};
|
|
|
|
#undef KWTUPLE
|
2019-03-14 05:32:22 -03:00
|
|
|
PyObject *argsbuf[3];
|
|
|
|
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
|
2015-05-04 09:32:48 -03:00
|
|
|
PyObject *path;
|
|
|
|
PyObject *default_value = Py_None;
|
|
|
|
PyObject *namespaces = Py_None;
|
|
|
|
|
2019-03-14 05:32:22 -03:00
|
|
|
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
|
|
|
|
if (!args) {
|
2015-05-04 09:32:48 -03:00
|
|
|
goto exit;
|
2016-06-09 10:16:06 -03:00
|
|
|
}
|
2019-03-14 05:32:22 -03:00
|
|
|
path = args[0];
|
|
|
|
if (!noptargs) {
|
|
|
|
goto skip_optional_pos;
|
|
|
|
}
|
|
|
|
if (args[1]) {
|
|
|
|
default_value = args[1];
|
|
|
|
if (!--noptargs) {
|
|
|
|
goto skip_optional_pos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
namespaces = args[2];
|
|
|
|
skip_optional_pos:
|
2023-01-24 12:00:24 -04:00
|
|
|
return_value = _elementtree_Element_findtext_impl(self, cls, path, default_value, namespaces);
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_Element_findall__doc__,
|
|
|
|
"findall($self, /, path, namespaces=None)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT_FINDALL_METHODDEF \
|
2023-01-24 12:00:24 -04:00
|
|
|
{"findall", _PyCFunction_CAST(_elementtree_Element_findall), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_findall__doc__},
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2023-01-24 12:00:24 -04:00
|
|
|
_elementtree_Element_findall_impl(ElementObject *self, PyTypeObject *cls,
|
|
|
|
PyObject *path, PyObject *namespaces);
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2023-01-24 12:00:24 -04:00
|
|
|
_elementtree_Element_findall(ElementObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
2015-05-04 09:32:48 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
2022-08-13 07:09:40 -03:00
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2022-08-13 07:09:40 -03:00
|
|
|
#define NUM_KEYWORDS 2
|
2022-08-11 18:25:49 -03:00
|
|
|
static struct {
|
|
|
|
PyGC_Head _this_is_not_used;
|
|
|
|
PyObject_VAR_HEAD
|
|
|
|
PyObject *ob_item[NUM_KEYWORDS];
|
|
|
|
} _kwtuple = {
|
|
|
|
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
|
|
|
|
.ob_item = { &_Py_ID(path), &_Py_ID(namespaces), },
|
|
|
|
};
|
|
|
|
#undef NUM_KEYWORDS
|
2022-08-13 07:09:40 -03:00
|
|
|
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
|
|
|
|
|
|
|
|
#else // !Py_BUILD_CORE
|
|
|
|
# define KWTUPLE NULL
|
|
|
|
#endif // !Py_BUILD_CORE
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2016-08-14 04:52:18 -03:00
|
|
|
static const char * const _keywords[] = {"path", "namespaces", NULL};
|
2022-08-11 18:25:49 -03:00
|
|
|
static _PyArg_Parser _parser = {
|
|
|
|
.keywords = _keywords,
|
|
|
|
.fname = "findall",
|
|
|
|
.kwtuple = KWTUPLE,
|
|
|
|
};
|
|
|
|
#undef KWTUPLE
|
2019-03-14 05:32:22 -03:00
|
|
|
PyObject *argsbuf[2];
|
|
|
|
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
|
2015-05-04 09:32:48 -03:00
|
|
|
PyObject *path;
|
|
|
|
PyObject *namespaces = Py_None;
|
|
|
|
|
2019-03-14 05:32:22 -03:00
|
|
|
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
|
|
|
|
if (!args) {
|
2015-05-04 09:32:48 -03:00
|
|
|
goto exit;
|
2016-06-09 10:16:06 -03:00
|
|
|
}
|
2019-03-14 05:32:22 -03:00
|
|
|
path = args[0];
|
|
|
|
if (!noptargs) {
|
|
|
|
goto skip_optional_pos;
|
|
|
|
}
|
|
|
|
namespaces = args[1];
|
|
|
|
skip_optional_pos:
|
2023-01-24 12:00:24 -04:00
|
|
|
return_value = _elementtree_Element_findall_impl(self, cls, path, namespaces);
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_Element_iterfind__doc__,
|
|
|
|
"iterfind($self, /, path, namespaces=None)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT_ITERFIND_METHODDEF \
|
2023-01-24 12:00:24 -04:00
|
|
|
{"iterfind", _PyCFunction_CAST(_elementtree_Element_iterfind), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_iterfind__doc__},
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2023-01-24 12:00:24 -04:00
|
|
|
_elementtree_Element_iterfind_impl(ElementObject *self, PyTypeObject *cls,
|
|
|
|
PyObject *path, PyObject *namespaces);
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2023-01-24 12:00:24 -04:00
|
|
|
_elementtree_Element_iterfind(ElementObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
2015-05-04 09:32:48 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
2022-08-13 07:09:40 -03:00
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2022-08-13 07:09:40 -03:00
|
|
|
#define NUM_KEYWORDS 2
|
2022-08-11 18:25:49 -03:00
|
|
|
static struct {
|
|
|
|
PyGC_Head _this_is_not_used;
|
|
|
|
PyObject_VAR_HEAD
|
|
|
|
PyObject *ob_item[NUM_KEYWORDS];
|
|
|
|
} _kwtuple = {
|
|
|
|
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
|
|
|
|
.ob_item = { &_Py_ID(path), &_Py_ID(namespaces), },
|
|
|
|
};
|
|
|
|
#undef NUM_KEYWORDS
|
2022-08-13 07:09:40 -03:00
|
|
|
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
|
|
|
|
|
|
|
|
#else // !Py_BUILD_CORE
|
|
|
|
# define KWTUPLE NULL
|
|
|
|
#endif // !Py_BUILD_CORE
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2016-08-14 04:52:18 -03:00
|
|
|
static const char * const _keywords[] = {"path", "namespaces", NULL};
|
2022-08-11 18:25:49 -03:00
|
|
|
static _PyArg_Parser _parser = {
|
|
|
|
.keywords = _keywords,
|
|
|
|
.fname = "iterfind",
|
|
|
|
.kwtuple = KWTUPLE,
|
|
|
|
};
|
|
|
|
#undef KWTUPLE
|
2019-03-14 05:32:22 -03:00
|
|
|
PyObject *argsbuf[2];
|
|
|
|
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
|
2015-05-04 09:32:48 -03:00
|
|
|
PyObject *path;
|
|
|
|
PyObject *namespaces = Py_None;
|
|
|
|
|
2019-03-14 05:32:22 -03:00
|
|
|
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
|
|
|
|
if (!args) {
|
2015-05-04 09:32:48 -03:00
|
|
|
goto exit;
|
2016-06-09 10:16:06 -03:00
|
|
|
}
|
2019-03-14 05:32:22 -03:00
|
|
|
path = args[0];
|
|
|
|
if (!noptargs) {
|
|
|
|
goto skip_optional_pos;
|
|
|
|
}
|
|
|
|
namespaces = args[1];
|
|
|
|
skip_optional_pos:
|
2023-01-24 12:00:24 -04:00
|
|
|
return_value = _elementtree_Element_iterfind_impl(self, cls, path, namespaces);
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_Element_get__doc__,
|
|
|
|
"get($self, /, key, default=None)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT_GET_METHODDEF \
|
2022-05-03 15:25:41 -03:00
|
|
|
{"get", _PyCFunction_CAST(_elementtree_Element_get), METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_get__doc__},
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_Element_get_impl(ElementObject *self, PyObject *key,
|
|
|
|
PyObject *default_value);
|
|
|
|
|
|
|
|
static PyObject *
|
2017-12-15 07:11:11 -04:00
|
|
|
_elementtree_Element_get(ElementObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
2015-05-04 09:32:48 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
2022-08-13 07:09:40 -03:00
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2022-08-13 07:09:40 -03:00
|
|
|
#define NUM_KEYWORDS 2
|
2022-08-11 18:25:49 -03:00
|
|
|
static struct {
|
|
|
|
PyGC_Head _this_is_not_used;
|
|
|
|
PyObject_VAR_HEAD
|
|
|
|
PyObject *ob_item[NUM_KEYWORDS];
|
|
|
|
} _kwtuple = {
|
|
|
|
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
|
|
|
|
.ob_item = { &_Py_ID(key), &_Py_ID(default), },
|
|
|
|
};
|
|
|
|
#undef NUM_KEYWORDS
|
2022-08-13 07:09:40 -03:00
|
|
|
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
|
|
|
|
|
|
|
|
#else // !Py_BUILD_CORE
|
|
|
|
# define KWTUPLE NULL
|
|
|
|
#endif // !Py_BUILD_CORE
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2016-08-14 04:52:18 -03:00
|
|
|
static const char * const _keywords[] = {"key", "default", NULL};
|
2022-08-11 18:25:49 -03:00
|
|
|
static _PyArg_Parser _parser = {
|
|
|
|
.keywords = _keywords,
|
|
|
|
.fname = "get",
|
|
|
|
.kwtuple = KWTUPLE,
|
|
|
|
};
|
|
|
|
#undef KWTUPLE
|
2019-03-14 05:32:22 -03:00
|
|
|
PyObject *argsbuf[2];
|
|
|
|
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
|
2015-05-04 09:32:48 -03:00
|
|
|
PyObject *key;
|
|
|
|
PyObject *default_value = Py_None;
|
|
|
|
|
2019-03-14 05:32:22 -03:00
|
|
|
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
|
|
|
|
if (!args) {
|
2015-05-04 09:32:48 -03:00
|
|
|
goto exit;
|
2016-06-09 10:16:06 -03:00
|
|
|
}
|
2019-03-14 05:32:22 -03:00
|
|
|
key = args[0];
|
|
|
|
if (!noptargs) {
|
|
|
|
goto skip_optional_pos;
|
|
|
|
}
|
|
|
|
default_value = args[1];
|
|
|
|
skip_optional_pos:
|
2015-05-04 09:32:48 -03:00
|
|
|
return_value = _elementtree_Element_get_impl(self, key, default_value);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_Element_iter__doc__,
|
|
|
|
"iter($self, /, tag=None)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT_ITER_METHODDEF \
|
2023-01-24 12:00:24 -04:00
|
|
|
{"iter", _PyCFunction_CAST(_elementtree_Element_iter), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_iter__doc__},
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2023-01-24 12:00:24 -04:00
|
|
|
_elementtree_Element_iter_impl(ElementObject *self, PyTypeObject *cls,
|
|
|
|
PyObject *tag);
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2023-01-24 12:00:24 -04:00
|
|
|
_elementtree_Element_iter(ElementObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
2015-05-04 09:32:48 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
2022-08-13 07:09:40 -03:00
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2022-08-13 07:09:40 -03:00
|
|
|
#define NUM_KEYWORDS 1
|
2022-08-11 18:25:49 -03:00
|
|
|
static struct {
|
|
|
|
PyGC_Head _this_is_not_used;
|
|
|
|
PyObject_VAR_HEAD
|
|
|
|
PyObject *ob_item[NUM_KEYWORDS];
|
|
|
|
} _kwtuple = {
|
|
|
|
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
|
|
|
|
.ob_item = { &_Py_ID(tag), },
|
|
|
|
};
|
|
|
|
#undef NUM_KEYWORDS
|
2022-08-13 07:09:40 -03:00
|
|
|
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
|
|
|
|
|
|
|
|
#else // !Py_BUILD_CORE
|
|
|
|
# define KWTUPLE NULL
|
|
|
|
#endif // !Py_BUILD_CORE
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2016-08-14 04:52:18 -03:00
|
|
|
static const char * const _keywords[] = {"tag", NULL};
|
2022-08-11 18:25:49 -03:00
|
|
|
static _PyArg_Parser _parser = {
|
|
|
|
.keywords = _keywords,
|
|
|
|
.fname = "iter",
|
|
|
|
.kwtuple = KWTUPLE,
|
|
|
|
};
|
|
|
|
#undef KWTUPLE
|
2019-03-14 05:32:22 -03:00
|
|
|
PyObject *argsbuf[1];
|
|
|
|
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
|
2015-05-04 09:32:48 -03:00
|
|
|
PyObject *tag = Py_None;
|
|
|
|
|
2019-03-14 05:32:22 -03:00
|
|
|
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
|
|
|
|
if (!args) {
|
2015-05-04 09:32:48 -03:00
|
|
|
goto exit;
|
2016-06-09 10:16:06 -03:00
|
|
|
}
|
2019-03-14 05:32:22 -03:00
|
|
|
if (!noptargs) {
|
|
|
|
goto skip_optional_pos;
|
|
|
|
}
|
|
|
|
tag = args[0];
|
|
|
|
skip_optional_pos:
|
2023-01-24 12:00:24 -04:00
|
|
|
return_value = _elementtree_Element_iter_impl(self, cls, tag);
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_Element_itertext__doc__,
|
|
|
|
"itertext($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT_ITERTEXT_METHODDEF \
|
2023-01-24 12:00:24 -04:00
|
|
|
{"itertext", _PyCFunction_CAST(_elementtree_Element_itertext), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_itertext__doc__},
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2023-01-24 12:00:24 -04:00
|
|
|
_elementtree_Element_itertext_impl(ElementObject *self, PyTypeObject *cls);
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2023-01-24 12:00:24 -04:00
|
|
|
_elementtree_Element_itertext(ElementObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
2015-05-04 09:32:48 -03:00
|
|
|
{
|
2023-01-24 12:00:24 -04:00
|
|
|
if (nargs) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "itertext() takes no arguments");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return _elementtree_Element_itertext_impl(self, cls);
|
2015-05-04 09:32:48 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_Element_insert__doc__,
|
|
|
|
"insert($self, index, subelement, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT_INSERT_METHODDEF \
|
2022-05-03 15:25:41 -03:00
|
|
|
{"insert", _PyCFunction_CAST(_elementtree_Element_insert), METH_FASTCALL, _elementtree_Element_insert__doc__},
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_Element_insert_impl(ElementObject *self, Py_ssize_t index,
|
|
|
|
PyObject *subelement);
|
|
|
|
|
|
|
|
static PyObject *
|
2017-12-15 07:11:11 -04:00
|
|
|
_elementtree_Element_insert(ElementObject *self, PyObject *const *args, Py_ssize_t nargs)
|
2015-05-04 09:32:48 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
Py_ssize_t index;
|
|
|
|
PyObject *subelement;
|
|
|
|
|
2019-01-11 10:01:14 -04:00
|
|
|
if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) {
|
2017-01-16 20:35:17 -04:00
|
|
|
goto exit;
|
|
|
|
}
|
2019-01-11 10:01:14 -04:00
|
|
|
{
|
|
|
|
Py_ssize_t ival = -1;
|
2020-05-28 04:33:45 -03:00
|
|
|
PyObject *iobj = _PyNumber_Index(args[0]);
|
2019-01-11 10:01:14 -04:00
|
|
|
if (iobj != NULL) {
|
|
|
|
ival = PyLong_AsSsize_t(iobj);
|
|
|
|
Py_DECREF(iobj);
|
|
|
|
}
|
|
|
|
if (ival == -1 && PyErr_Occurred()) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
index = ival;
|
|
|
|
}
|
2023-01-21 07:01:15 -04:00
|
|
|
if (!PyObject_TypeCheck(args[1], clinic_state()->Element_Type)) {
|
|
|
|
_PyArg_BadArgument("insert", "argument 2", (clinic_state()->Element_Type)->tp_name, args[1]);
|
2019-01-11 10:01:14 -04:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
subelement = args[1];
|
2015-05-04 09:32:48 -03:00
|
|
|
return_value = _elementtree_Element_insert_impl(self, index, subelement);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_Element_items__doc__,
|
|
|
|
"items($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT_ITEMS_METHODDEF \
|
|
|
|
{"items", (PyCFunction)_elementtree_Element_items, METH_NOARGS, _elementtree_Element_items__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_Element_items_impl(ElementObject *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_Element_items(ElementObject *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
return _elementtree_Element_items_impl(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_Element_keys__doc__,
|
|
|
|
"keys($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT_KEYS_METHODDEF \
|
|
|
|
{"keys", (PyCFunction)_elementtree_Element_keys, METH_NOARGS, _elementtree_Element_keys__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_Element_keys_impl(ElementObject *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_Element_keys(ElementObject *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
return _elementtree_Element_keys_impl(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_Element_makeelement__doc__,
|
|
|
|
"makeelement($self, tag, attrib, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT_MAKEELEMENT_METHODDEF \
|
2023-01-24 12:00:24 -04:00
|
|
|
{"makeelement", _PyCFunction_CAST(_elementtree_Element_makeelement), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_makeelement__doc__},
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2023-01-24 12:00:24 -04:00
|
|
|
_elementtree_Element_makeelement_impl(ElementObject *self, PyTypeObject *cls,
|
|
|
|
PyObject *tag, PyObject *attrib);
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
2023-01-24 12:00:24 -04:00
|
|
|
_elementtree_Element_makeelement(ElementObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
2015-05-04 09:32:48 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
2023-01-24 12:00:24 -04:00
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
|
|
|
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
|
|
|
|
#else
|
|
|
|
# define KWTUPLE NULL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static const char * const _keywords[] = {"", "", NULL};
|
|
|
|
static _PyArg_Parser _parser = {
|
|
|
|
.keywords = _keywords,
|
|
|
|
.fname = "makeelement",
|
|
|
|
.kwtuple = KWTUPLE,
|
|
|
|
};
|
|
|
|
#undef KWTUPLE
|
|
|
|
PyObject *argsbuf[2];
|
2015-05-04 09:32:48 -03:00
|
|
|
PyObject *tag;
|
|
|
|
PyObject *attrib;
|
|
|
|
|
2023-01-24 12:00:24 -04:00
|
|
|
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
|
|
|
|
if (!args) {
|
2017-01-16 21:21:47 -04:00
|
|
|
goto exit;
|
|
|
|
}
|
2019-01-11 12:01:42 -04:00
|
|
|
tag = args[0];
|
2020-03-09 10:12:41 -03:00
|
|
|
if (!PyDict_Check(args[1])) {
|
|
|
|
_PyArg_BadArgument("makeelement", "argument 2", "dict", args[1]);
|
|
|
|
goto exit;
|
|
|
|
}
|
2019-01-11 12:01:42 -04:00
|
|
|
attrib = args[1];
|
2023-01-24 12:00:24 -04:00
|
|
|
return_value = _elementtree_Element_makeelement_impl(self, cls, tag, attrib);
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_Element_remove__doc__,
|
|
|
|
"remove($self, subelement, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT_REMOVE_METHODDEF \
|
|
|
|
{"remove", (PyCFunction)_elementtree_Element_remove, METH_O, _elementtree_Element_remove__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_Element_remove_impl(ElementObject *self, PyObject *subelement);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_Element_remove(ElementObject *self, PyObject *arg)
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
PyObject *subelement;
|
|
|
|
|
2023-01-21 07:01:15 -04:00
|
|
|
if (!PyObject_TypeCheck(arg, clinic_state()->Element_Type)) {
|
|
|
|
_PyArg_BadArgument("remove", "argument", (clinic_state()->Element_Type)->tp_name, arg);
|
2015-05-04 09:32:48 -03:00
|
|
|
goto exit;
|
2016-06-09 10:16:06 -03:00
|
|
|
}
|
2018-12-25 07:23:47 -04:00
|
|
|
subelement = arg;
|
2015-05-04 09:32:48 -03:00
|
|
|
return_value = _elementtree_Element_remove_impl(self, subelement);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_Element_set__doc__,
|
|
|
|
"set($self, key, value, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_ELEMENT_SET_METHODDEF \
|
2022-05-03 15:25:41 -03:00
|
|
|
{"set", _PyCFunction_CAST(_elementtree_Element_set), METH_FASTCALL, _elementtree_Element_set__doc__},
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_Element_set_impl(ElementObject *self, PyObject *key,
|
|
|
|
PyObject *value);
|
|
|
|
|
|
|
|
static PyObject *
|
2017-12-15 07:11:11 -04:00
|
|
|
_elementtree_Element_set(ElementObject *self, PyObject *const *args, Py_ssize_t nargs)
|
2015-05-04 09:32:48 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
PyObject *key;
|
|
|
|
PyObject *value;
|
|
|
|
|
2019-01-11 12:01:42 -04:00
|
|
|
if (!_PyArg_CheckPositional("set", nargs, 2, 2)) {
|
2017-01-16 21:21:47 -04:00
|
|
|
goto exit;
|
|
|
|
}
|
2019-01-11 12:01:42 -04:00
|
|
|
key = args[0];
|
|
|
|
value = args[1];
|
2015-05-04 09:32:48 -03:00
|
|
|
return_value = _elementtree_Element_set_impl(self, key, value);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_elementtree_TreeBuilder___init___impl(TreeBuilderObject *self,
|
2019-05-01 16:20:38 -03:00
|
|
|
PyObject *element_factory,
|
|
|
|
PyObject *comment_factory,
|
|
|
|
PyObject *pi_factory,
|
|
|
|
int insert_comments, int insert_pis);
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static int
|
|
|
|
_elementtree_TreeBuilder___init__(PyObject *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
int return_value = -1;
|
2022-08-13 07:09:40 -03:00
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2022-08-13 07:09:40 -03:00
|
|
|
#define NUM_KEYWORDS 5
|
2022-08-11 18:25:49 -03:00
|
|
|
static struct {
|
|
|
|
PyGC_Head _this_is_not_used;
|
|
|
|
PyObject_VAR_HEAD
|
|
|
|
PyObject *ob_item[NUM_KEYWORDS];
|
|
|
|
} _kwtuple = {
|
|
|
|
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
|
|
|
|
.ob_item = { &_Py_ID(element_factory), &_Py_ID(comment_factory), &_Py_ID(pi_factory), &_Py_ID(insert_comments), &_Py_ID(insert_pis), },
|
|
|
|
};
|
|
|
|
#undef NUM_KEYWORDS
|
2022-08-13 07:09:40 -03:00
|
|
|
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
|
|
|
|
|
|
|
|
#else // !Py_BUILD_CORE
|
|
|
|
# define KWTUPLE NULL
|
|
|
|
#endif // !Py_BUILD_CORE
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2019-05-01 16:20:38 -03:00
|
|
|
static const char * const _keywords[] = {"element_factory", "comment_factory", "pi_factory", "insert_comments", "insert_pis", NULL};
|
2022-08-11 18:25:49 -03:00
|
|
|
static _PyArg_Parser _parser = {
|
|
|
|
.keywords = _keywords,
|
|
|
|
.fname = "TreeBuilder",
|
|
|
|
.kwtuple = KWTUPLE,
|
|
|
|
};
|
|
|
|
#undef KWTUPLE
|
2019-05-01 16:20:38 -03:00
|
|
|
PyObject *argsbuf[5];
|
2019-03-14 05:32:22 -03:00
|
|
|
PyObject * const *fastargs;
|
|
|
|
Py_ssize_t nargs = PyTuple_GET_SIZE(args);
|
|
|
|
Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0;
|
2019-09-14 06:24:05 -03:00
|
|
|
PyObject *element_factory = Py_None;
|
|
|
|
PyObject *comment_factory = Py_None;
|
|
|
|
PyObject *pi_factory = Py_None;
|
2019-05-01 16:20:38 -03:00
|
|
|
int insert_comments = 0;
|
|
|
|
int insert_pis = 0;
|
2015-05-04 09:32:48 -03:00
|
|
|
|
2019-03-14 05:32:22 -03:00
|
|
|
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 1, 0, argsbuf);
|
|
|
|
if (!fastargs) {
|
2015-05-04 09:32:48 -03:00
|
|
|
goto exit;
|
2016-06-09 10:16:06 -03:00
|
|
|
}
|
2019-03-14 05:32:22 -03:00
|
|
|
if (!noptargs) {
|
|
|
|
goto skip_optional_pos;
|
|
|
|
}
|
2019-05-01 16:20:38 -03:00
|
|
|
if (fastargs[0]) {
|
|
|
|
element_factory = fastargs[0];
|
|
|
|
if (!--noptargs) {
|
|
|
|
goto skip_optional_pos;
|
|
|
|
}
|
|
|
|
}
|
2019-03-14 05:32:22 -03:00
|
|
|
skip_optional_pos:
|
2019-05-01 16:20:38 -03:00
|
|
|
if (!noptargs) {
|
|
|
|
goto skip_optional_kwonly;
|
|
|
|
}
|
|
|
|
if (fastargs[1]) {
|
|
|
|
comment_factory = fastargs[1];
|
|
|
|
if (!--noptargs) {
|
|
|
|
goto skip_optional_kwonly;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fastargs[2]) {
|
|
|
|
pi_factory = fastargs[2];
|
|
|
|
if (!--noptargs) {
|
|
|
|
goto skip_optional_kwonly;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fastargs[3]) {
|
|
|
|
insert_comments = PyObject_IsTrue(fastargs[3]);
|
|
|
|
if (insert_comments < 0) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
if (!--noptargs) {
|
|
|
|
goto skip_optional_kwonly;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
insert_pis = PyObject_IsTrue(fastargs[4]);
|
|
|
|
if (insert_pis < 0) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
skip_optional_kwonly:
|
|
|
|
return_value = _elementtree_TreeBuilder___init___impl((TreeBuilderObject *)self, element_factory, comment_factory, pi_factory, insert_comments, insert_pis);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree__set_factories__doc__,
|
|
|
|
"_set_factories($module, comment_factory, pi_factory, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Change the factories used to create comments and processing instructions.\n"
|
|
|
|
"\n"
|
|
|
|
"For internal use only.");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE__SET_FACTORIES_METHODDEF \
|
2022-05-03 15:25:41 -03:00
|
|
|
{"_set_factories", _PyCFunction_CAST(_elementtree__set_factories), METH_FASTCALL, _elementtree__set_factories__doc__},
|
2019-05-01 16:20:38 -03:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree__set_factories_impl(PyObject *module, PyObject *comment_factory,
|
|
|
|
PyObject *pi_factory);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree__set_factories(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
PyObject *comment_factory;
|
|
|
|
PyObject *pi_factory;
|
|
|
|
|
|
|
|
if (!_PyArg_CheckPositional("_set_factories", nargs, 2, 2)) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
comment_factory = args[0];
|
|
|
|
pi_factory = args[1];
|
|
|
|
return_value = _elementtree__set_factories_impl(module, comment_factory, pi_factory);
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_TreeBuilder_data__doc__,
|
|
|
|
"data($self, data, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_TREEBUILDER_DATA_METHODDEF \
|
|
|
|
{"data", (PyCFunction)_elementtree_TreeBuilder_data, METH_O, _elementtree_TreeBuilder_data__doc__},
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_TreeBuilder_end__doc__,
|
|
|
|
"end($self, tag, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_TREEBUILDER_END_METHODDEF \
|
|
|
|
{"end", (PyCFunction)_elementtree_TreeBuilder_end, METH_O, _elementtree_TreeBuilder_end__doc__},
|
|
|
|
|
2019-05-01 16:20:38 -03:00
|
|
|
PyDoc_STRVAR(_elementtree_TreeBuilder_comment__doc__,
|
|
|
|
"comment($self, text, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_TREEBUILDER_COMMENT_METHODDEF \
|
|
|
|
{"comment", (PyCFunction)_elementtree_TreeBuilder_comment, METH_O, _elementtree_TreeBuilder_comment__doc__},
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_TreeBuilder_pi__doc__,
|
|
|
|
"pi($self, target, text=None, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_TREEBUILDER_PI_METHODDEF \
|
2022-05-03 15:25:41 -03:00
|
|
|
{"pi", _PyCFunction_CAST(_elementtree_TreeBuilder_pi), METH_FASTCALL, _elementtree_TreeBuilder_pi__doc__},
|
2019-05-01 16:20:38 -03:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_TreeBuilder_pi_impl(TreeBuilderObject *self, PyObject *target,
|
|
|
|
PyObject *text);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_TreeBuilder_pi(TreeBuilderObject *self, PyObject *const *args, Py_ssize_t nargs)
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
PyObject *target;
|
|
|
|
PyObject *text = Py_None;
|
|
|
|
|
|
|
|
if (!_PyArg_CheckPositional("pi", nargs, 1, 2)) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
target = args[0];
|
|
|
|
if (nargs < 2) {
|
|
|
|
goto skip_optional;
|
|
|
|
}
|
|
|
|
text = args[1];
|
|
|
|
skip_optional:
|
|
|
|
return_value = _elementtree_TreeBuilder_pi_impl(self, target, text);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
2015-05-04 09:32:48 -03:00
|
|
|
PyDoc_STRVAR(_elementtree_TreeBuilder_close__doc__,
|
|
|
|
"close($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_TREEBUILDER_CLOSE_METHODDEF \
|
|
|
|
{"close", (PyCFunction)_elementtree_TreeBuilder_close, METH_NOARGS, _elementtree_TreeBuilder_close__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_TreeBuilder_close_impl(TreeBuilderObject *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_TreeBuilder_close(TreeBuilderObject *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
return _elementtree_TreeBuilder_close_impl(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_TreeBuilder_start__doc__,
|
2020-03-02 02:33:24 -04:00
|
|
|
"start($self, tag, attrs, /)\n"
|
2015-05-04 09:32:48 -03:00
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_TREEBUILDER_START_METHODDEF \
|
2022-05-03 15:25:41 -03:00
|
|
|
{"start", _PyCFunction_CAST(_elementtree_TreeBuilder_start), METH_FASTCALL, _elementtree_TreeBuilder_start__doc__},
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_TreeBuilder_start_impl(TreeBuilderObject *self, PyObject *tag,
|
|
|
|
PyObject *attrs);
|
|
|
|
|
|
|
|
static PyObject *
|
2017-12-15 07:11:11 -04:00
|
|
|
_elementtree_TreeBuilder_start(TreeBuilderObject *self, PyObject *const *args, Py_ssize_t nargs)
|
2015-05-04 09:32:48 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
PyObject *tag;
|
2020-03-02 02:33:24 -04:00
|
|
|
PyObject *attrs;
|
2015-05-04 09:32:48 -03:00
|
|
|
|
2020-03-02 02:33:24 -04:00
|
|
|
if (!_PyArg_CheckPositional("start", nargs, 2, 2)) {
|
2017-01-16 21:21:47 -04:00
|
|
|
goto exit;
|
|
|
|
}
|
2019-01-11 12:01:42 -04:00
|
|
|
tag = args[0];
|
2020-03-02 02:33:24 -04:00
|
|
|
if (!PyDict_Check(args[1])) {
|
|
|
|
_PyArg_BadArgument("start", "argument 2", "dict", args[1]);
|
|
|
|
goto exit;
|
2019-01-11 12:01:42 -04:00
|
|
|
}
|
|
|
|
attrs = args[1];
|
2015-05-04 09:32:48 -03:00
|
|
|
return_value = _elementtree_TreeBuilder_start_impl(self, tag, attrs);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2018-07-24 06:03:34 -03:00
|
|
|
_elementtree_XMLParser___init___impl(XMLParserObject *self, PyObject *target,
|
|
|
|
const char *encoding);
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static int
|
|
|
|
_elementtree_XMLParser___init__(PyObject *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
int return_value = -1;
|
2022-08-13 07:09:40 -03:00
|
|
|
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2022-08-13 07:09:40 -03:00
|
|
|
#define NUM_KEYWORDS 2
|
2022-08-11 18:25:49 -03:00
|
|
|
static struct {
|
|
|
|
PyGC_Head _this_is_not_used;
|
|
|
|
PyObject_VAR_HEAD
|
|
|
|
PyObject *ob_item[NUM_KEYWORDS];
|
|
|
|
} _kwtuple = {
|
|
|
|
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
|
|
|
|
.ob_item = { &_Py_ID(target), &_Py_ID(encoding), },
|
|
|
|
};
|
|
|
|
#undef NUM_KEYWORDS
|
2022-08-13 07:09:40 -03:00
|
|
|
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
|
|
|
|
|
|
|
|
#else // !Py_BUILD_CORE
|
|
|
|
# define KWTUPLE NULL
|
|
|
|
#endif // !Py_BUILD_CORE
|
2022-08-11 18:25:49 -03:00
|
|
|
|
2018-07-24 06:03:34 -03:00
|
|
|
static const char * const _keywords[] = {"target", "encoding", NULL};
|
2022-08-11 18:25:49 -03:00
|
|
|
static _PyArg_Parser _parser = {
|
|
|
|
.keywords = _keywords,
|
|
|
|
.fname = "XMLParser",
|
|
|
|
.kwtuple = KWTUPLE,
|
|
|
|
};
|
|
|
|
#undef KWTUPLE
|
2019-03-14 05:32:22 -03:00
|
|
|
PyObject *argsbuf[2];
|
|
|
|
PyObject * const *fastargs;
|
|
|
|
Py_ssize_t nargs = PyTuple_GET_SIZE(args);
|
|
|
|
Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0;
|
2022-02-12 04:27:02 -04:00
|
|
|
PyObject *target = Py_None;
|
2015-05-04 09:32:48 -03:00
|
|
|
const char *encoding = NULL;
|
|
|
|
|
2019-03-14 05:32:22 -03:00
|
|
|
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 0, 0, argsbuf);
|
|
|
|
if (!fastargs) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
if (!noptargs) {
|
|
|
|
goto skip_optional_kwonly;
|
|
|
|
}
|
|
|
|
if (fastargs[0]) {
|
|
|
|
target = fastargs[0];
|
|
|
|
if (!--noptargs) {
|
|
|
|
goto skip_optional_kwonly;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fastargs[1] == Py_None) {
|
|
|
|
encoding = NULL;
|
|
|
|
}
|
|
|
|
else if (PyUnicode_Check(fastargs[1])) {
|
2023-11-07 18:36:13 -04:00
|
|
|
Py_ssize_t encoding_length;
|
|
|
|
encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length);
|
2019-03-14 05:32:22 -03:00
|
|
|
if (encoding == NULL) {
|
|
|
|
goto exit;
|
|
|
|
}
|
2023-11-07 18:36:13 -04:00
|
|
|
if (strlen(encoding) != (size_t)encoding_length) {
|
|
|
|
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
|
|
|
goto exit;
|
|
|
|
}
|
2019-03-14 05:32:22 -03:00
|
|
|
}
|
|
|
|
else {
|
2019-08-29 11:49:08 -03:00
|
|
|
_PyArg_BadArgument("XMLParser", "argument 'encoding'", "str or None", fastargs[1]);
|
2015-05-04 09:32:48 -03:00
|
|
|
goto exit;
|
2016-06-09 10:16:06 -03:00
|
|
|
}
|
2019-03-14 05:32:22 -03:00
|
|
|
skip_optional_kwonly:
|
2018-07-24 06:03:34 -03:00
|
|
|
return_value = _elementtree_XMLParser___init___impl((XMLParserObject *)self, target, encoding);
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_XMLParser_close__doc__,
|
|
|
|
"close($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_XMLPARSER_CLOSE_METHODDEF \
|
|
|
|
{"close", (PyCFunction)_elementtree_XMLParser_close, METH_NOARGS, _elementtree_XMLParser_close__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_XMLParser_close_impl(XMLParserObject *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_XMLParser_close(XMLParserObject *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
return _elementtree_XMLParser_close_impl(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_XMLParser_feed__doc__,
|
|
|
|
"feed($self, data, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_XMLPARSER_FEED_METHODDEF \
|
|
|
|
{"feed", (PyCFunction)_elementtree_XMLParser_feed, METH_O, _elementtree_XMLParser_feed__doc__},
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_XMLParser__parse_whole__doc__,
|
|
|
|
"_parse_whole($self, file, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_XMLPARSER__PARSE_WHOLE_METHODDEF \
|
|
|
|
{"_parse_whole", (PyCFunction)_elementtree_XMLParser__parse_whole, METH_O, _elementtree_XMLParser__parse_whole__doc__},
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_elementtree_XMLParser__setevents__doc__,
|
|
|
|
"_setevents($self, events_queue, events_to_report=None, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n");
|
|
|
|
|
|
|
|
#define _ELEMENTTREE_XMLPARSER__SETEVENTS_METHODDEF \
|
2022-05-03 15:25:41 -03:00
|
|
|
{"_setevents", _PyCFunction_CAST(_elementtree_XMLParser__setevents), METH_FASTCALL, _elementtree_XMLParser__setevents__doc__},
|
2015-05-04 09:32:48 -03:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_elementtree_XMLParser__setevents_impl(XMLParserObject *self,
|
|
|
|
PyObject *events_queue,
|
|
|
|
PyObject *events_to_report);
|
|
|
|
|
|
|
|
static PyObject *
|
2017-12-15 07:11:11 -04:00
|
|
|
_elementtree_XMLParser__setevents(XMLParserObject *self, PyObject *const *args, Py_ssize_t nargs)
|
2015-05-04 09:32:48 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
PyObject *events_queue;
|
|
|
|
PyObject *events_to_report = Py_None;
|
|
|
|
|
2019-01-11 12:01:42 -04:00
|
|
|
if (!_PyArg_CheckPositional("_setevents", nargs, 1, 2)) {
|
2017-01-16 21:21:47 -04:00
|
|
|
goto exit;
|
|
|
|
}
|
2019-01-11 12:01:42 -04:00
|
|
|
events_queue = args[0];
|
|
|
|
if (nargs < 2) {
|
|
|
|
goto skip_optional;
|
|
|
|
}
|
|
|
|
events_to_report = args[1];
|
|
|
|
skip_optional:
|
2015-05-04 09:32:48 -03:00
|
|
|
return_value = _elementtree_XMLParser__setevents_impl(self, events_queue, events_to_report);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
2023-11-07 18:36:13 -04:00
|
|
|
/*[clinic end generated code: output=8fdaa17d3262800a input=a9049054013a1b77]*/
|