| 1 |
/*[clinic input] |
| 2 |
preserve |
| 3 |
[clinic start generated code]*/ |
| 4 |
|
| 5 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 6 |
# include "pycore_gc.h" // PyGC_Head |
| 7 |
# include "pycore_runtime.h" // _Py_SINGLETON() |
| 8 |
#endif |
| 9 |
#include "pycore_abstract.h" // _PyNumber_Index() |
| 10 |
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() |
| 11 |
|
| 12 |
PyDoc_STRVAR(_elementtree_Element_append__doc__, |
| 13 |
"append($self, subelement, /)\n" |
| 14 |
"--\n" |
| 15 |
"\n"); |
| 16 |
|
| 17 |
#define _ELEMENTTREE_ELEMENT_APPEND_METHODDEF \ |
| 18 |
{"append", _PyCFunction_CAST(_elementtree_Element_append), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_append__doc__}, |
| 19 |
|
| 20 |
static PyObject * |
| 21 |
_elementtree_Element_append_impl(ElementObject *self, PyTypeObject *cls, |
| 22 |
PyObject *subelement); |
| 23 |
|
| 24 |
static PyObject * |
| 25 |
_elementtree_Element_append(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 26 |
{ |
| 27 |
PyObject *return_value = NULL; |
| 28 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 29 |
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
| 30 |
#else |
| 31 |
# define KWTUPLE NULL |
| 32 |
#endif |
| 33 |
|
| 34 |
static const char * const _keywords[] = {"", NULL}; |
| 35 |
static _PyArg_Parser _parser = { |
| 36 |
.keywords = _keywords, |
| 37 |
.fname = "append", |
| 38 |
.kwtuple = KWTUPLE, |
| 39 |
}; |
| 40 |
#undef KWTUPLE |
| 41 |
PyObject *argsbuf[1]; |
| 42 |
PyObject *subelement; |
| 43 |
|
| 44 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 45 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 46 |
if (!args) { |
| 47 |
goto exit; |
| 48 |
} |
| 49 |
if (!PyObject_TypeCheck(args[0], clinic_state()->Element_Type)) { |
| 50 |
_PyArg_BadArgument("append", "argument 1", (clinic_state()->Element_Type)->tp_name, args[0]); |
| 51 |
goto exit; |
| 52 |
} |
| 53 |
subelement = args[0]; |
| 54 |
return_value = _elementtree_Element_append_impl((ElementObject *)self, cls, subelement); |
| 55 |
|
| 56 |
exit: |
| 57 |
return return_value; |
| 58 |
} |
| 59 |
|
| 60 |
PyDoc_STRVAR(_elementtree_Element_clear__doc__, |
| 61 |
"clear($self, /)\n" |
| 62 |
"--\n" |
| 63 |
"\n"); |
| 64 |
|
| 65 |
#define _ELEMENTTREE_ELEMENT_CLEAR_METHODDEF \ |
| 66 |
{"clear", (PyCFunction)_elementtree_Element_clear, METH_NOARGS, _elementtree_Element_clear__doc__}, |
| 67 |
|
| 68 |
static PyObject * |
| 69 |
_elementtree_Element_clear_impl(ElementObject *self); |
| 70 |
|
| 71 |
static PyObject * |
| 72 |
_elementtree_Element_clear(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 73 |
{ |
| 74 |
return _elementtree_Element_clear_impl((ElementObject *)self); |
| 75 |
} |
| 76 |
|
| 77 |
PyDoc_STRVAR(_elementtree_Element___copy____doc__, |
| 78 |
"__copy__($self, /)\n" |
| 79 |
"--\n" |
| 80 |
"\n"); |
| 81 |
|
| 82 |
#define _ELEMENTTREE_ELEMENT___COPY___METHODDEF \ |
| 83 |
{"__copy__", _PyCFunction_CAST(_elementtree_Element___copy__), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element___copy____doc__}, |
| 84 |
|
| 85 |
static PyObject * |
| 86 |
_elementtree_Element___copy___impl(ElementObject *self, PyTypeObject *cls); |
| 87 |
|
| 88 |
static PyObject * |
| 89 |
_elementtree_Element___copy__(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 90 |
{ |
| 91 |
if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) { |
| 92 |
PyErr_SetString(PyExc_TypeError, "__copy__() takes no arguments"); |
| 93 |
return NULL; |
| 94 |
} |
| 95 |
return _elementtree_Element___copy___impl((ElementObject *)self, cls); |
| 96 |
} |
| 97 |
|
| 98 |
PyDoc_STRVAR(_elementtree_Element___deepcopy____doc__, |
| 99 |
"__deepcopy__($self, memo, /)\n" |
| 100 |
"--\n" |
| 101 |
"\n"); |
| 102 |
|
| 103 |
#define _ELEMENTTREE_ELEMENT___DEEPCOPY___METHODDEF \ |
| 104 |
{"__deepcopy__", (PyCFunction)_elementtree_Element___deepcopy__, METH_O, _elementtree_Element___deepcopy____doc__}, |
| 105 |
|
| 106 |
static PyObject * |
| 107 |
_elementtree_Element___deepcopy___impl(ElementObject *self, PyObject *memo); |
| 108 |
|
| 109 |
static PyObject * |
| 110 |
_elementtree_Element___deepcopy__(PyObject *self, PyObject *arg) |
| 111 |
{ |
| 112 |
PyObject *return_value = NULL; |
| 113 |
PyObject *memo; |
| 114 |
|
| 115 |
if (!PyDict_Check(arg)) { |
| 116 |
_PyArg_BadArgument("__deepcopy__", "argument", "dict", arg); |
| 117 |
goto exit; |
| 118 |
} |
| 119 |
memo = arg; |
| 120 |
return_value = _elementtree_Element___deepcopy___impl((ElementObject *)self, memo); |
| 121 |
|
| 122 |
exit: |
| 123 |
return return_value; |
| 124 |
} |
| 125 |
|
| 126 |
PyDoc_STRVAR(_elementtree_Element___sizeof____doc__, |
| 127 |
"__sizeof__($self, /)\n" |
| 128 |
"--\n" |
| 129 |
"\n"); |
| 130 |
|
| 131 |
#define _ELEMENTTREE_ELEMENT___SIZEOF___METHODDEF \ |
| 132 |
{"__sizeof__", (PyCFunction)_elementtree_Element___sizeof__, METH_NOARGS, _elementtree_Element___sizeof____doc__}, |
| 133 |
|
| 134 |
static size_t |
| 135 |
_elementtree_Element___sizeof___impl(ElementObject *self); |
| 136 |
|
| 137 |
static PyObject * |
| 138 |
_elementtree_Element___sizeof__(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 139 |
{ |
| 140 |
PyObject *return_value = NULL; |
| 141 |
size_t _return_value; |
| 142 |
|
| 143 |
_return_value = _elementtree_Element___sizeof___impl((ElementObject *)self); |
| 144 |
if ((_return_value == (size_t)-1) && PyErr_Occurred()) { |
| 145 |
goto exit; |
| 146 |
} |
| 147 |
return_value = PyLong_FromSize_t(_return_value); |
| 148 |
|
| 149 |
exit: |
| 150 |
return return_value; |
| 151 |
} |
| 152 |
|
| 153 |
PyDoc_STRVAR(_elementtree_Element___getstate____doc__, |
| 154 |
"__getstate__($self, /)\n" |
| 155 |
"--\n" |
| 156 |
"\n"); |
| 157 |
|
| 158 |
#define _ELEMENTTREE_ELEMENT___GETSTATE___METHODDEF \ |
| 159 |
{"__getstate__", (PyCFunction)_elementtree_Element___getstate__, METH_NOARGS, _elementtree_Element___getstate____doc__}, |
| 160 |
|
| 161 |
static PyObject * |
| 162 |
_elementtree_Element___getstate___impl(ElementObject *self); |
| 163 |
|
| 164 |
static PyObject * |
| 165 |
_elementtree_Element___getstate__(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 166 |
{ |
| 167 |
return _elementtree_Element___getstate___impl((ElementObject *)self); |
| 168 |
} |
| 169 |
|
| 170 |
PyDoc_STRVAR(_elementtree_Element___setstate____doc__, |
| 171 |
"__setstate__($self, state, /)\n" |
| 172 |
"--\n" |
| 173 |
"\n"); |
| 174 |
|
| 175 |
#define _ELEMENTTREE_ELEMENT___SETSTATE___METHODDEF \ |
| 176 |
{"__setstate__", _PyCFunction_CAST(_elementtree_Element___setstate__), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element___setstate____doc__}, |
| 177 |
|
| 178 |
static PyObject * |
| 179 |
_elementtree_Element___setstate___impl(ElementObject *self, |
| 180 |
PyTypeObject *cls, PyObject *state); |
| 181 |
|
| 182 |
static PyObject * |
| 183 |
_elementtree_Element___setstate__(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 184 |
{ |
| 185 |
PyObject *return_value = NULL; |
| 186 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 187 |
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
| 188 |
#else |
| 189 |
# define KWTUPLE NULL |
| 190 |
#endif |
| 191 |
|
| 192 |
static const char * const _keywords[] = {"", NULL}; |
| 193 |
static _PyArg_Parser _parser = { |
| 194 |
.keywords = _keywords, |
| 195 |
.fname = "__setstate__", |
| 196 |
.kwtuple = KWTUPLE, |
| 197 |
}; |
| 198 |
#undef KWTUPLE |
| 199 |
PyObject *argsbuf[1]; |
| 200 |
PyObject *state; |
| 201 |
|
| 202 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 203 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 204 |
if (!args) { |
| 205 |
goto exit; |
| 206 |
} |
| 207 |
state = args[0]; |
| 208 |
return_value = _elementtree_Element___setstate___impl((ElementObject *)self, cls, state); |
| 209 |
|
| 210 |
exit: |
| 211 |
return return_value; |
| 212 |
} |
| 213 |
|
| 214 |
PyDoc_STRVAR(_elementtree_Element_extend__doc__, |
| 215 |
"extend($self, elements, /)\n" |
| 216 |
"--\n" |
| 217 |
"\n"); |
| 218 |
|
| 219 |
#define _ELEMENTTREE_ELEMENT_EXTEND_METHODDEF \ |
| 220 |
{"extend", _PyCFunction_CAST(_elementtree_Element_extend), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_extend__doc__}, |
| 221 |
|
| 222 |
static PyObject * |
| 223 |
_elementtree_Element_extend_impl(ElementObject *self, PyTypeObject *cls, |
| 224 |
PyObject *elements); |
| 225 |
|
| 226 |
static PyObject * |
| 227 |
_elementtree_Element_extend(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 228 |
{ |
| 229 |
PyObject *return_value = NULL; |
| 230 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 231 |
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
| 232 |
#else |
| 233 |
# define KWTUPLE NULL |
| 234 |
#endif |
| 235 |
|
| 236 |
static const char * const _keywords[] = {"", NULL}; |
| 237 |
static _PyArg_Parser _parser = { |
| 238 |
.keywords = _keywords, |
| 239 |
.fname = "extend", |
| 240 |
.kwtuple = KWTUPLE, |
| 241 |
}; |
| 242 |
#undef KWTUPLE |
| 243 |
PyObject *argsbuf[1]; |
| 244 |
PyObject *elements; |
| 245 |
|
| 246 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 247 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 248 |
if (!args) { |
| 249 |
goto exit; |
| 250 |
} |
| 251 |
elements = args[0]; |
| 252 |
return_value = _elementtree_Element_extend_impl((ElementObject *)self, cls, elements); |
| 253 |
|
| 254 |
exit: |
| 255 |
return return_value; |
| 256 |
} |
| 257 |
|
| 258 |
PyDoc_STRVAR(_elementtree_Element_find__doc__, |
| 259 |
"find($self, /, path, namespaces=None)\n" |
| 260 |
"--\n" |
| 261 |
"\n"); |
| 262 |
|
| 263 |
#define _ELEMENTTREE_ELEMENT_FIND_METHODDEF \ |
| 264 |
{"find", _PyCFunction_CAST(_elementtree_Element_find), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_find__doc__}, |
| 265 |
|
| 266 |
static PyObject * |
| 267 |
_elementtree_Element_find_impl(ElementObject *self, PyTypeObject *cls, |
| 268 |
PyObject *path, PyObject *namespaces); |
| 269 |
|
| 270 |
static PyObject * |
| 271 |
_elementtree_Element_find(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 272 |
{ |
| 273 |
PyObject *return_value = NULL; |
| 274 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 275 |
|
| 276 |
#define NUM_KEYWORDS 2 |
| 277 |
static struct { |
| 278 |
PyGC_Head _this_is_not_used; |
| 279 |
PyObject_VAR_HEAD |
| 280 |
Py_hash_t ob_hash; |
| 281 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 282 |
} _kwtuple = { |
| 283 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 284 |
.ob_hash = -1, |
| 285 |
.ob_item = { &_Py_ID(path), &_Py_ID(namespaces), }, |
| 286 |
}; |
| 287 |
#undef NUM_KEYWORDS |
| 288 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 289 |
|
| 290 |
#else // !Py_BUILD_CORE |
| 291 |
# define KWTUPLE NULL |
| 292 |
#endif // !Py_BUILD_CORE |
| 293 |
|
| 294 |
static const char * const _keywords[] = {"path", "namespaces", NULL}; |
| 295 |
static _PyArg_Parser _parser = { |
| 296 |
.keywords = _keywords, |
| 297 |
.fname = "find", |
| 298 |
.kwtuple = KWTUPLE, |
| 299 |
}; |
| 300 |
#undef KWTUPLE |
| 301 |
PyObject *argsbuf[2]; |
| 302 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 303 |
PyObject *path; |
| 304 |
PyObject *namespaces = Py_None; |
| 305 |
|
| 306 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 307 |
/*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 308 |
if (!args) { |
| 309 |
goto exit; |
| 310 |
} |
| 311 |
path = args[0]; |
| 312 |
if (!noptargs) { |
| 313 |
goto skip_optional_pos; |
| 314 |
} |
| 315 |
namespaces = args[1]; |
| 316 |
skip_optional_pos: |
| 317 |
return_value = _elementtree_Element_find_impl((ElementObject *)self, cls, path, namespaces); |
| 318 |
|
| 319 |
exit: |
| 320 |
return return_value; |
| 321 |
} |
| 322 |
|
| 323 |
PyDoc_STRVAR(_elementtree_Element_findtext__doc__, |
| 324 |
"findtext($self, /, path, default=None, namespaces=None)\n" |
| 325 |
"--\n" |
| 326 |
"\n"); |
| 327 |
|
| 328 |
#define _ELEMENTTREE_ELEMENT_FINDTEXT_METHODDEF \ |
| 329 |
{"findtext", _PyCFunction_CAST(_elementtree_Element_findtext), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_findtext__doc__}, |
| 330 |
|
| 331 |
static PyObject * |
| 332 |
_elementtree_Element_findtext_impl(ElementObject *self, PyTypeObject *cls, |
| 333 |
PyObject *path, PyObject *default_value, |
| 334 |
PyObject *namespaces); |
| 335 |
|
| 336 |
static PyObject * |
| 337 |
_elementtree_Element_findtext(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 338 |
{ |
| 339 |
PyObject *return_value = NULL; |
| 340 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 341 |
|
| 342 |
#define NUM_KEYWORDS 3 |
| 343 |
static struct { |
| 344 |
PyGC_Head _this_is_not_used; |
| 345 |
PyObject_VAR_HEAD |
| 346 |
Py_hash_t ob_hash; |
| 347 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 348 |
} _kwtuple = { |
| 349 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 350 |
.ob_hash = -1, |
| 351 |
.ob_item = { &_Py_ID(path), &_Py_ID(default), &_Py_ID(namespaces), }, |
| 352 |
}; |
| 353 |
#undef NUM_KEYWORDS |
| 354 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 355 |
|
| 356 |
#else // !Py_BUILD_CORE |
| 357 |
# define KWTUPLE NULL |
| 358 |
#endif // !Py_BUILD_CORE |
| 359 |
|
| 360 |
static const char * const _keywords[] = {"path", "default", "namespaces", NULL}; |
| 361 |
static _PyArg_Parser _parser = { |
| 362 |
.keywords = _keywords, |
| 363 |
.fname = "findtext", |
| 364 |
.kwtuple = KWTUPLE, |
| 365 |
}; |
| 366 |
#undef KWTUPLE |
| 367 |
PyObject *argsbuf[3]; |
| 368 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 369 |
PyObject *path; |
| 370 |
PyObject *default_value = Py_None; |
| 371 |
PyObject *namespaces = Py_None; |
| 372 |
|
| 373 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 374 |
/*minpos*/ 1, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 375 |
if (!args) { |
| 376 |
goto exit; |
| 377 |
} |
| 378 |
path = args[0]; |
| 379 |
if (!noptargs) { |
| 380 |
goto skip_optional_pos; |
| 381 |
} |
| 382 |
if (args[1]) { |
| 383 |
default_value = args[1]; |
| 384 |
if (!--noptargs) { |
| 385 |
goto skip_optional_pos; |
| 386 |
} |
| 387 |
} |
| 388 |
namespaces = args[2]; |
| 389 |
skip_optional_pos: |
| 390 |
return_value = _elementtree_Element_findtext_impl((ElementObject *)self, cls, path, default_value, namespaces); |
| 391 |
|
| 392 |
exit: |
| 393 |
return return_value; |
| 394 |
} |
| 395 |
|
| 396 |
PyDoc_STRVAR(_elementtree_Element_findall__doc__, |
| 397 |
"findall($self, /, path, namespaces=None)\n" |
| 398 |
"--\n" |
| 399 |
"\n"); |
| 400 |
|
| 401 |
#define _ELEMENTTREE_ELEMENT_FINDALL_METHODDEF \ |
| 402 |
{"findall", _PyCFunction_CAST(_elementtree_Element_findall), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_findall__doc__}, |
| 403 |
|
| 404 |
static PyObject * |
| 405 |
_elementtree_Element_findall_impl(ElementObject *self, PyTypeObject *cls, |
| 406 |
PyObject *path, PyObject *namespaces); |
| 407 |
|
| 408 |
static PyObject * |
| 409 |
_elementtree_Element_findall(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 410 |
{ |
| 411 |
PyObject *return_value = NULL; |
| 412 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 413 |
|
| 414 |
#define NUM_KEYWORDS 2 |
| 415 |
static struct { |
| 416 |
PyGC_Head _this_is_not_used; |
| 417 |
PyObject_VAR_HEAD |
| 418 |
Py_hash_t ob_hash; |
| 419 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 420 |
} _kwtuple = { |
| 421 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 422 |
.ob_hash = -1, |
| 423 |
.ob_item = { &_Py_ID(path), &_Py_ID(namespaces), }, |
| 424 |
}; |
| 425 |
#undef NUM_KEYWORDS |
| 426 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 427 |
|
| 428 |
#else // !Py_BUILD_CORE |
| 429 |
# define KWTUPLE NULL |
| 430 |
#endif // !Py_BUILD_CORE |
| 431 |
|
| 432 |
static const char * const _keywords[] = {"path", "namespaces", NULL}; |
| 433 |
static _PyArg_Parser _parser = { |
| 434 |
.keywords = _keywords, |
| 435 |
.fname = "findall", |
| 436 |
.kwtuple = KWTUPLE, |
| 437 |
}; |
| 438 |
#undef KWTUPLE |
| 439 |
PyObject *argsbuf[2]; |
| 440 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 441 |
PyObject *path; |
| 442 |
PyObject *namespaces = Py_None; |
| 443 |
|
| 444 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 445 |
/*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 446 |
if (!args) { |
| 447 |
goto exit; |
| 448 |
} |
| 449 |
path = args[0]; |
| 450 |
if (!noptargs) { |
| 451 |
goto skip_optional_pos; |
| 452 |
} |
| 453 |
namespaces = args[1]; |
| 454 |
skip_optional_pos: |
| 455 |
return_value = _elementtree_Element_findall_impl((ElementObject *)self, cls, path, namespaces); |
| 456 |
|
| 457 |
exit: |
| 458 |
return return_value; |
| 459 |
} |
| 460 |
|
| 461 |
PyDoc_STRVAR(_elementtree_Element_iterfind__doc__, |
| 462 |
"iterfind($self, /, path, namespaces=None)\n" |
| 463 |
"--\n" |
| 464 |
"\n"); |
| 465 |
|
| 466 |
#define _ELEMENTTREE_ELEMENT_ITERFIND_METHODDEF \ |
| 467 |
{"iterfind", _PyCFunction_CAST(_elementtree_Element_iterfind), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_iterfind__doc__}, |
| 468 |
|
| 469 |
static PyObject * |
| 470 |
_elementtree_Element_iterfind_impl(ElementObject *self, PyTypeObject *cls, |
| 471 |
PyObject *path, PyObject *namespaces); |
| 472 |
|
| 473 |
static PyObject * |
| 474 |
_elementtree_Element_iterfind(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 475 |
{ |
| 476 |
PyObject *return_value = NULL; |
| 477 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 478 |
|
| 479 |
#define NUM_KEYWORDS 2 |
| 480 |
static struct { |
| 481 |
PyGC_Head _this_is_not_used; |
| 482 |
PyObject_VAR_HEAD |
| 483 |
Py_hash_t ob_hash; |
| 484 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 485 |
} _kwtuple = { |
| 486 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 487 |
.ob_hash = -1, |
| 488 |
.ob_item = { &_Py_ID(path), &_Py_ID(namespaces), }, |
| 489 |
}; |
| 490 |
#undef NUM_KEYWORDS |
| 491 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 492 |
|
| 493 |
#else // !Py_BUILD_CORE |
| 494 |
# define KWTUPLE NULL |
| 495 |
#endif // !Py_BUILD_CORE |
| 496 |
|
| 497 |
static const char * const _keywords[] = {"path", "namespaces", NULL}; |
| 498 |
static _PyArg_Parser _parser = { |
| 499 |
.keywords = _keywords, |
| 500 |
.fname = "iterfind", |
| 501 |
.kwtuple = KWTUPLE, |
| 502 |
}; |
| 503 |
#undef KWTUPLE |
| 504 |
PyObject *argsbuf[2]; |
| 505 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 506 |
PyObject *path; |
| 507 |
PyObject *namespaces = Py_None; |
| 508 |
|
| 509 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 510 |
/*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 511 |
if (!args) { |
| 512 |
goto exit; |
| 513 |
} |
| 514 |
path = args[0]; |
| 515 |
if (!noptargs) { |
| 516 |
goto skip_optional_pos; |
| 517 |
} |
| 518 |
namespaces = args[1]; |
| 519 |
skip_optional_pos: |
| 520 |
return_value = _elementtree_Element_iterfind_impl((ElementObject *)self, cls, path, namespaces); |
| 521 |
|
| 522 |
exit: |
| 523 |
return return_value; |
| 524 |
} |
| 525 |
|
| 526 |
PyDoc_STRVAR(_elementtree_Element_get__doc__, |
| 527 |
"get($self, /, key, default=None)\n" |
| 528 |
"--\n" |
| 529 |
"\n"); |
| 530 |
|
| 531 |
#define _ELEMENTTREE_ELEMENT_GET_METHODDEF \ |
| 532 |
{"get", _PyCFunction_CAST(_elementtree_Element_get), METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_get__doc__}, |
| 533 |
|
| 534 |
static PyObject * |
| 535 |
_elementtree_Element_get_impl(ElementObject *self, PyObject *key, |
| 536 |
PyObject *default_value); |
| 537 |
|
| 538 |
static PyObject * |
| 539 |
_elementtree_Element_get(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 540 |
{ |
| 541 |
PyObject *return_value = NULL; |
| 542 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 543 |
|
| 544 |
#define NUM_KEYWORDS 2 |
| 545 |
static struct { |
| 546 |
PyGC_Head _this_is_not_used; |
| 547 |
PyObject_VAR_HEAD |
| 548 |
Py_hash_t ob_hash; |
| 549 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 550 |
} _kwtuple = { |
| 551 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 552 |
.ob_hash = -1, |
| 553 |
.ob_item = { &_Py_ID(key), &_Py_ID(default), }, |
| 554 |
}; |
| 555 |
#undef NUM_KEYWORDS |
| 556 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 557 |
|
| 558 |
#else // !Py_BUILD_CORE |
| 559 |
# define KWTUPLE NULL |
| 560 |
#endif // !Py_BUILD_CORE |
| 561 |
|
| 562 |
static const char * const _keywords[] = {"key", "default", NULL}; |
| 563 |
static _PyArg_Parser _parser = { |
| 564 |
.keywords = _keywords, |
| 565 |
.fname = "get", |
| 566 |
.kwtuple = KWTUPLE, |
| 567 |
}; |
| 568 |
#undef KWTUPLE |
| 569 |
PyObject *argsbuf[2]; |
| 570 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 571 |
PyObject *key; |
| 572 |
PyObject *default_value = Py_None; |
| 573 |
|
| 574 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 575 |
/*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 576 |
if (!args) { |
| 577 |
goto exit; |
| 578 |
} |
| 579 |
key = args[0]; |
| 580 |
if (!noptargs) { |
| 581 |
goto skip_optional_pos; |
| 582 |
} |
| 583 |
default_value = args[1]; |
| 584 |
skip_optional_pos: |
| 585 |
return_value = _elementtree_Element_get_impl((ElementObject *)self, key, default_value); |
| 586 |
|
| 587 |
exit: |
| 588 |
return return_value; |
| 589 |
} |
| 590 |
|
| 591 |
PyDoc_STRVAR(_elementtree_Element_iter__doc__, |
| 592 |
"iter($self, /, tag=None)\n" |
| 593 |
"--\n" |
| 594 |
"\n"); |
| 595 |
|
| 596 |
#define _ELEMENTTREE_ELEMENT_ITER_METHODDEF \ |
| 597 |
{"iter", _PyCFunction_CAST(_elementtree_Element_iter), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_iter__doc__}, |
| 598 |
|
| 599 |
static PyObject * |
| 600 |
_elementtree_Element_iter_impl(ElementObject *self, PyTypeObject *cls, |
| 601 |
PyObject *tag); |
| 602 |
|
| 603 |
static PyObject * |
| 604 |
_elementtree_Element_iter(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 605 |
{ |
| 606 |
PyObject *return_value = NULL; |
| 607 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 608 |
|
| 609 |
#define NUM_KEYWORDS 1 |
| 610 |
static struct { |
| 611 |
PyGC_Head _this_is_not_used; |
| 612 |
PyObject_VAR_HEAD |
| 613 |
Py_hash_t ob_hash; |
| 614 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 615 |
} _kwtuple = { |
| 616 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 617 |
.ob_hash = -1, |
| 618 |
.ob_item = { &_Py_ID(tag), }, |
| 619 |
}; |
| 620 |
#undef NUM_KEYWORDS |
| 621 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 622 |
|
| 623 |
#else // !Py_BUILD_CORE |
| 624 |
# define KWTUPLE NULL |
| 625 |
#endif // !Py_BUILD_CORE |
| 626 |
|
| 627 |
static const char * const _keywords[] = {"tag", NULL}; |
| 628 |
static _PyArg_Parser _parser = { |
| 629 |
.keywords = _keywords, |
| 630 |
.fname = "iter", |
| 631 |
.kwtuple = KWTUPLE, |
| 632 |
}; |
| 633 |
#undef KWTUPLE |
| 634 |
PyObject *argsbuf[1]; |
| 635 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
| 636 |
PyObject *tag = Py_None; |
| 637 |
|
| 638 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 639 |
/*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 640 |
if (!args) { |
| 641 |
goto exit; |
| 642 |
} |
| 643 |
if (!noptargs) { |
| 644 |
goto skip_optional_pos; |
| 645 |
} |
| 646 |
tag = args[0]; |
| 647 |
skip_optional_pos: |
| 648 |
return_value = _elementtree_Element_iter_impl((ElementObject *)self, cls, tag); |
| 649 |
|
| 650 |
exit: |
| 651 |
return return_value; |
| 652 |
} |
| 653 |
|
| 654 |
PyDoc_STRVAR(_elementtree_Element_itertext__doc__, |
| 655 |
"itertext($self, /)\n" |
| 656 |
"--\n" |
| 657 |
"\n"); |
| 658 |
|
| 659 |
#define _ELEMENTTREE_ELEMENT_ITERTEXT_METHODDEF \ |
| 660 |
{"itertext", _PyCFunction_CAST(_elementtree_Element_itertext), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_itertext__doc__}, |
| 661 |
|
| 662 |
static PyObject * |
| 663 |
_elementtree_Element_itertext_impl(ElementObject *self, PyTypeObject *cls); |
| 664 |
|
| 665 |
static PyObject * |
| 666 |
_elementtree_Element_itertext(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 667 |
{ |
| 668 |
if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) { |
| 669 |
PyErr_SetString(PyExc_TypeError, "itertext() takes no arguments"); |
| 670 |
return NULL; |
| 671 |
} |
| 672 |
return _elementtree_Element_itertext_impl((ElementObject *)self, cls); |
| 673 |
} |
| 674 |
|
| 675 |
PyDoc_STRVAR(_elementtree_Element_insert__doc__, |
| 676 |
"insert($self, index, subelement, /)\n" |
| 677 |
"--\n" |
| 678 |
"\n"); |
| 679 |
|
| 680 |
#define _ELEMENTTREE_ELEMENT_INSERT_METHODDEF \ |
| 681 |
{"insert", _PyCFunction_CAST(_elementtree_Element_insert), METH_FASTCALL, _elementtree_Element_insert__doc__}, |
| 682 |
|
| 683 |
static PyObject * |
| 684 |
_elementtree_Element_insert_impl(ElementObject *self, Py_ssize_t index, |
| 685 |
PyObject *subelement); |
| 686 |
|
| 687 |
static PyObject * |
| 688 |
_elementtree_Element_insert(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
| 689 |
{ |
| 690 |
PyObject *return_value = NULL; |
| 691 |
Py_ssize_t index; |
| 692 |
PyObject *subelement; |
| 693 |
|
| 694 |
if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) { |
| 695 |
goto exit; |
| 696 |
} |
| 697 |
{ |
| 698 |
Py_ssize_t ival = -1; |
| 699 |
PyObject *iobj = _PyNumber_Index(args[0]); |
| 700 |
if (iobj != NULL) { |
| 701 |
ival = PyLong_AsSsize_t(iobj); |
| 702 |
Py_DECREF(iobj); |
| 703 |
} |
| 704 |
if (ival == -1 && PyErr_Occurred()) { |
| 705 |
goto exit; |
| 706 |
} |
| 707 |
index = ival; |
| 708 |
} |
| 709 |
if (!PyObject_TypeCheck(args[1], clinic_state()->Element_Type)) { |
| 710 |
_PyArg_BadArgument("insert", "argument 2", (clinic_state()->Element_Type)->tp_name, args[1]); |
| 711 |
goto exit; |
| 712 |
} |
| 713 |
subelement = args[1]; |
| 714 |
return_value = _elementtree_Element_insert_impl((ElementObject *)self, index, subelement); |
| 715 |
|
| 716 |
exit: |
| 717 |
return return_value; |
| 718 |
} |
| 719 |
|
| 720 |
PyDoc_STRVAR(_elementtree_Element_items__doc__, |
| 721 |
"items($self, /)\n" |
| 722 |
"--\n" |
| 723 |
"\n"); |
| 724 |
|
| 725 |
#define _ELEMENTTREE_ELEMENT_ITEMS_METHODDEF \ |
| 726 |
{"items", (PyCFunction)_elementtree_Element_items, METH_NOARGS, _elementtree_Element_items__doc__}, |
| 727 |
|
| 728 |
static PyObject * |
| 729 |
_elementtree_Element_items_impl(ElementObject *self); |
| 730 |
|
| 731 |
static PyObject * |
| 732 |
_elementtree_Element_items(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 733 |
{ |
| 734 |
return _elementtree_Element_items_impl((ElementObject *)self); |
| 735 |
} |
| 736 |
|
| 737 |
PyDoc_STRVAR(_elementtree_Element_keys__doc__, |
| 738 |
"keys($self, /)\n" |
| 739 |
"--\n" |
| 740 |
"\n"); |
| 741 |
|
| 742 |
#define _ELEMENTTREE_ELEMENT_KEYS_METHODDEF \ |
| 743 |
{"keys", (PyCFunction)_elementtree_Element_keys, METH_NOARGS, _elementtree_Element_keys__doc__}, |
| 744 |
|
| 745 |
static PyObject * |
| 746 |
_elementtree_Element_keys_impl(ElementObject *self); |
| 747 |
|
| 748 |
static PyObject * |
| 749 |
_elementtree_Element_keys(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 750 |
{ |
| 751 |
return _elementtree_Element_keys_impl((ElementObject *)self); |
| 752 |
} |
| 753 |
|
| 754 |
PyDoc_STRVAR(_elementtree_Element_makeelement__doc__, |
| 755 |
"makeelement($self, tag, attrib, /)\n" |
| 756 |
"--\n" |
| 757 |
"\n"); |
| 758 |
|
| 759 |
#define _ELEMENTTREE_ELEMENT_MAKEELEMENT_METHODDEF \ |
| 760 |
{"makeelement", _PyCFunction_CAST(_elementtree_Element_makeelement), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_makeelement__doc__}, |
| 761 |
|
| 762 |
static PyObject * |
| 763 |
_elementtree_Element_makeelement_impl(ElementObject *self, PyTypeObject *cls, |
| 764 |
PyObject *tag, PyObject *attrib); |
| 765 |
|
| 766 |
static PyObject * |
| 767 |
_elementtree_Element_makeelement(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 768 |
{ |
| 769 |
PyObject *return_value = NULL; |
| 770 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 771 |
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) |
| 772 |
#else |
| 773 |
# define KWTUPLE NULL |
| 774 |
#endif |
| 775 |
|
| 776 |
static const char * const _keywords[] = {"", "", NULL}; |
| 777 |
static _PyArg_Parser _parser = { |
| 778 |
.keywords = _keywords, |
| 779 |
.fname = "makeelement", |
| 780 |
.kwtuple = KWTUPLE, |
| 781 |
}; |
| 782 |
#undef KWTUPLE |
| 783 |
PyObject *argsbuf[2]; |
| 784 |
PyObject *tag; |
| 785 |
PyObject *attrib; |
| 786 |
|
| 787 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 788 |
/*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 789 |
if (!args) { |
| 790 |
goto exit; |
| 791 |
} |
| 792 |
tag = args[0]; |
| 793 |
if (!PyDict_Check(args[1])) { |
| 794 |
_PyArg_BadArgument("makeelement", "argument 2", "dict", args[1]); |
| 795 |
goto exit; |
| 796 |
} |
| 797 |
attrib = args[1]; |
| 798 |
return_value = _elementtree_Element_makeelement_impl((ElementObject *)self, cls, tag, attrib); |
| 799 |
|
| 800 |
exit: |
| 801 |
return return_value; |
| 802 |
} |
| 803 |
|
| 804 |
PyDoc_STRVAR(_elementtree_Element_remove__doc__, |
| 805 |
"remove($self, subelement, /)\n" |
| 806 |
"--\n" |
| 807 |
"\n"); |
| 808 |
|
| 809 |
#define _ELEMENTTREE_ELEMENT_REMOVE_METHODDEF \ |
| 810 |
{"remove", (PyCFunction)_elementtree_Element_remove, METH_O, _elementtree_Element_remove__doc__}, |
| 811 |
|
| 812 |
static PyObject * |
| 813 |
_elementtree_Element_remove_impl(ElementObject *self, PyObject *subelement); |
| 814 |
|
| 815 |
static PyObject * |
| 816 |
_elementtree_Element_remove(PyObject *self, PyObject *arg) |
| 817 |
{ |
| 818 |
PyObject *return_value = NULL; |
| 819 |
PyObject *subelement; |
| 820 |
|
| 821 |
if (!PyObject_TypeCheck(arg, clinic_state()->Element_Type)) { |
| 822 |
_PyArg_BadArgument("remove", "argument", (clinic_state()->Element_Type)->tp_name, arg); |
| 823 |
goto exit; |
| 824 |
} |
| 825 |
subelement = arg; |
| 826 |
return_value = _elementtree_Element_remove_impl((ElementObject *)self, subelement); |
| 827 |
|
| 828 |
exit: |
| 829 |
return return_value; |
| 830 |
} |
| 831 |
|
| 832 |
PyDoc_STRVAR(_elementtree_Element_set__doc__, |
| 833 |
"set($self, key, value, /)\n" |
| 834 |
"--\n" |
| 835 |
"\n"); |
| 836 |
|
| 837 |
#define _ELEMENTTREE_ELEMENT_SET_METHODDEF \ |
| 838 |
{"set", _PyCFunction_CAST(_elementtree_Element_set), METH_FASTCALL, _elementtree_Element_set__doc__}, |
| 839 |
|
| 840 |
static PyObject * |
| 841 |
_elementtree_Element_set_impl(ElementObject *self, PyObject *key, |
| 842 |
PyObject *value); |
| 843 |
|
| 844 |
static PyObject * |
| 845 |
_elementtree_Element_set(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
| 846 |
{ |
| 847 |
PyObject *return_value = NULL; |
| 848 |
PyObject *key; |
| 849 |
PyObject *value; |
| 850 |
|
| 851 |
if (!_PyArg_CheckPositional("set", nargs, 2, 2)) { |
| 852 |
goto exit; |
| 853 |
} |
| 854 |
key = args[0]; |
| 855 |
value = args[1]; |
| 856 |
return_value = _elementtree_Element_set_impl((ElementObject *)self, key, value); |
| 857 |
|
| 858 |
exit: |
| 859 |
return return_value; |
| 860 |
} |
| 861 |
|
| 862 |
static int |
| 863 |
_elementtree_TreeBuilder___init___impl(TreeBuilderObject *self, |
| 864 |
PyObject *element_factory, |
| 865 |
PyObject *comment_factory, |
| 866 |
PyObject *pi_factory, |
| 867 |
int insert_comments, int insert_pis); |
| 868 |
|
| 869 |
static int |
| 870 |
_elementtree_TreeBuilder___init__(PyObject *self, PyObject *args, PyObject *kwargs) |
| 871 |
{ |
| 872 |
int return_value = -1; |
| 873 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 874 |
|
| 875 |
#define NUM_KEYWORDS 5 |
| 876 |
static struct { |
| 877 |
PyGC_Head _this_is_not_used; |
| 878 |
PyObject_VAR_HEAD |
| 879 |
Py_hash_t ob_hash; |
| 880 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 881 |
} _kwtuple = { |
| 882 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 883 |
.ob_hash = -1, |
| 884 |
.ob_item = { &_Py_ID(element_factory), &_Py_ID(comment_factory), &_Py_ID(pi_factory), &_Py_ID(insert_comments), &_Py_ID(insert_pis), }, |
| 885 |
}; |
| 886 |
#undef NUM_KEYWORDS |
| 887 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 888 |
|
| 889 |
#else // !Py_BUILD_CORE |
| 890 |
# define KWTUPLE NULL |
| 891 |
#endif // !Py_BUILD_CORE |
| 892 |
|
| 893 |
static const char * const _keywords[] = {"element_factory", "comment_factory", "pi_factory", "insert_comments", "insert_pis", NULL}; |
| 894 |
static _PyArg_Parser _parser = { |
| 895 |
.keywords = _keywords, |
| 896 |
.fname = "TreeBuilder", |
| 897 |
.kwtuple = KWTUPLE, |
| 898 |
}; |
| 899 |
#undef KWTUPLE |
| 900 |
PyObject *argsbuf[5]; |
| 901 |
PyObject * const *fastargs; |
| 902 |
Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
| 903 |
Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; |
| 904 |
PyObject *element_factory = Py_None; |
| 905 |
PyObject *comment_factory = Py_None; |
| 906 |
PyObject *pi_factory = Py_None; |
| 907 |
int insert_comments = 0; |
| 908 |
int insert_pis = 0; |
| 909 |
|
| 910 |
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, |
| 911 |
/*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 912 |
if (!fastargs) { |
| 913 |
goto exit; |
| 914 |
} |
| 915 |
if (!noptargs) { |
| 916 |
goto skip_optional_pos; |
| 917 |
} |
| 918 |
if (fastargs[0]) { |
| 919 |
element_factory = fastargs[0]; |
| 920 |
if (!--noptargs) { |
| 921 |
goto skip_optional_pos; |
| 922 |
} |
| 923 |
} |
| 924 |
skip_optional_pos: |
| 925 |
if (!noptargs) { |
| 926 |
goto skip_optional_kwonly; |
| 927 |
} |
| 928 |
if (fastargs[1]) { |
| 929 |
comment_factory = fastargs[1]; |
| 930 |
if (!--noptargs) { |
| 931 |
goto skip_optional_kwonly; |
| 932 |
} |
| 933 |
} |
| 934 |
if (fastargs[2]) { |
| 935 |
pi_factory = fastargs[2]; |
| 936 |
if (!--noptargs) { |
| 937 |
goto skip_optional_kwonly; |
| 938 |
} |
| 939 |
} |
| 940 |
if (fastargs[3]) { |
| 941 |
insert_comments = PyObject_IsTrue(fastargs[3]); |
| 942 |
if (insert_comments < 0) { |
| 943 |
goto exit; |
| 944 |
} |
| 945 |
if (!--noptargs) { |
| 946 |
goto skip_optional_kwonly; |
| 947 |
} |
| 948 |
} |
| 949 |
insert_pis = PyObject_IsTrue(fastargs[4]); |
| 950 |
if (insert_pis < 0) { |
| 951 |
goto exit; |
| 952 |
} |
| 953 |
skip_optional_kwonly: |
| 954 |
return_value = _elementtree_TreeBuilder___init___impl((TreeBuilderObject *)self, element_factory, comment_factory, pi_factory, insert_comments, insert_pis); |
| 955 |
|
| 956 |
exit: |
| 957 |
return return_value; |
| 958 |
} |
| 959 |
|
| 960 |
PyDoc_STRVAR(_elementtree__set_factories__doc__, |
| 961 |
"_set_factories($module, comment_factory, pi_factory, /)\n" |
| 962 |
"--\n" |
| 963 |
"\n" |
| 964 |
"Change the factories used to create comments and processing instructions.\n" |
| 965 |
"\n" |
| 966 |
"For internal use only."); |
| 967 |
|
| 968 |
#define _ELEMENTTREE__SET_FACTORIES_METHODDEF \ |
| 969 |
{"_set_factories", _PyCFunction_CAST(_elementtree__set_factories), METH_FASTCALL, _elementtree__set_factories__doc__}, |
| 970 |
|
| 971 |
static PyObject * |
| 972 |
_elementtree__set_factories_impl(PyObject *module, PyObject *comment_factory, |
| 973 |
PyObject *pi_factory); |
| 974 |
|
| 975 |
static PyObject * |
| 976 |
_elementtree__set_factories(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 977 |
{ |
| 978 |
PyObject *return_value = NULL; |
| 979 |
PyObject *comment_factory; |
| 980 |
PyObject *pi_factory; |
| 981 |
|
| 982 |
if (!_PyArg_CheckPositional("_set_factories", nargs, 2, 2)) { |
| 983 |
goto exit; |
| 984 |
} |
| 985 |
comment_factory = args[0]; |
| 986 |
pi_factory = args[1]; |
| 987 |
return_value = _elementtree__set_factories_impl(module, comment_factory, pi_factory); |
| 988 |
|
| 989 |
exit: |
| 990 |
return return_value; |
| 991 |
} |
| 992 |
|
| 993 |
PyDoc_STRVAR(_elementtree_TreeBuilder_data__doc__, |
| 994 |
"data($self, data, /)\n" |
| 995 |
"--\n" |
| 996 |
"\n"); |
| 997 |
|
| 998 |
#define _ELEMENTTREE_TREEBUILDER_DATA_METHODDEF \ |
| 999 |
{"data", (PyCFunction)_elementtree_TreeBuilder_data, METH_O, _elementtree_TreeBuilder_data__doc__}, |
| 1000 |
|
| 1001 |
static PyObject * |
| 1002 |
_elementtree_TreeBuilder_data_impl(TreeBuilderObject *self, PyObject *data); |
| 1003 |
|
| 1004 |
static PyObject * |
| 1005 |
_elementtree_TreeBuilder_data(PyObject *self, PyObject *data) |
| 1006 |
{ |
| 1007 |
PyObject *return_value = NULL; |
| 1008 |
|
| 1009 |
return_value = _elementtree_TreeBuilder_data_impl((TreeBuilderObject *)self, data); |
| 1010 |
|
| 1011 |
return return_value; |
| 1012 |
} |
| 1013 |
|
| 1014 |
PyDoc_STRVAR(_elementtree_TreeBuilder_end__doc__, |
| 1015 |
"end($self, tag, /)\n" |
| 1016 |
"--\n" |
| 1017 |
"\n"); |
| 1018 |
|
| 1019 |
#define _ELEMENTTREE_TREEBUILDER_END_METHODDEF \ |
| 1020 |
{"end", (PyCFunction)_elementtree_TreeBuilder_end, METH_O, _elementtree_TreeBuilder_end__doc__}, |
| 1021 |
|
| 1022 |
static PyObject * |
| 1023 |
_elementtree_TreeBuilder_end_impl(TreeBuilderObject *self, PyObject *tag); |
| 1024 |
|
| 1025 |
static PyObject * |
| 1026 |
_elementtree_TreeBuilder_end(PyObject *self, PyObject *tag) |
| 1027 |
{ |
| 1028 |
PyObject *return_value = NULL; |
| 1029 |
|
| 1030 |
return_value = _elementtree_TreeBuilder_end_impl((TreeBuilderObject *)self, tag); |
| 1031 |
|
| 1032 |
return return_value; |
| 1033 |
} |
| 1034 |
|
| 1035 |
PyDoc_STRVAR(_elementtree_TreeBuilder_comment__doc__, |
| 1036 |
"comment($self, text, /)\n" |
| 1037 |
"--\n" |
| 1038 |
"\n"); |
| 1039 |
|
| 1040 |
#define _ELEMENTTREE_TREEBUILDER_COMMENT_METHODDEF \ |
| 1041 |
{"comment", (PyCFunction)_elementtree_TreeBuilder_comment, METH_O, _elementtree_TreeBuilder_comment__doc__}, |
| 1042 |
|
| 1043 |
static PyObject * |
| 1044 |
_elementtree_TreeBuilder_comment_impl(TreeBuilderObject *self, |
| 1045 |
PyObject *text); |
| 1046 |
|
| 1047 |
static PyObject * |
| 1048 |
_elementtree_TreeBuilder_comment(PyObject *self, PyObject *text) |
| 1049 |
{ |
| 1050 |
PyObject *return_value = NULL; |
| 1051 |
|
| 1052 |
return_value = _elementtree_TreeBuilder_comment_impl((TreeBuilderObject *)self, text); |
| 1053 |
|
| 1054 |
return return_value; |
| 1055 |
} |
| 1056 |
|
| 1057 |
PyDoc_STRVAR(_elementtree_TreeBuilder_pi__doc__, |
| 1058 |
"pi($self, target, text=None, /)\n" |
| 1059 |
"--\n" |
| 1060 |
"\n"); |
| 1061 |
|
| 1062 |
#define _ELEMENTTREE_TREEBUILDER_PI_METHODDEF \ |
| 1063 |
{"pi", _PyCFunction_CAST(_elementtree_TreeBuilder_pi), METH_FASTCALL, _elementtree_TreeBuilder_pi__doc__}, |
| 1064 |
|
| 1065 |
static PyObject * |
| 1066 |
_elementtree_TreeBuilder_pi_impl(TreeBuilderObject *self, PyObject *target, |
| 1067 |
PyObject *text); |
| 1068 |
|
| 1069 |
static PyObject * |
| 1070 |
_elementtree_TreeBuilder_pi(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
| 1071 |
{ |
| 1072 |
PyObject *return_value = NULL; |
| 1073 |
PyObject *target; |
| 1074 |
PyObject *text = Py_None; |
| 1075 |
|
| 1076 |
if (!_PyArg_CheckPositional("pi", nargs, 1, 2)) { |
| 1077 |
goto exit; |
| 1078 |
} |
| 1079 |
target = args[0]; |
| 1080 |
if (nargs < 2) { |
| 1081 |
goto skip_optional; |
| 1082 |
} |
| 1083 |
text = args[1]; |
| 1084 |
skip_optional: |
| 1085 |
return_value = _elementtree_TreeBuilder_pi_impl((TreeBuilderObject *)self, target, text); |
| 1086 |
|
| 1087 |
exit: |
| 1088 |
return return_value; |
| 1089 |
} |
| 1090 |
|
| 1091 |
PyDoc_STRVAR(_elementtree_TreeBuilder_close__doc__, |
| 1092 |
"close($self, /)\n" |
| 1093 |
"--\n" |
| 1094 |
"\n"); |
| 1095 |
|
| 1096 |
#define _ELEMENTTREE_TREEBUILDER_CLOSE_METHODDEF \ |
| 1097 |
{"close", (PyCFunction)_elementtree_TreeBuilder_close, METH_NOARGS, _elementtree_TreeBuilder_close__doc__}, |
| 1098 |
|
| 1099 |
static PyObject * |
| 1100 |
_elementtree_TreeBuilder_close_impl(TreeBuilderObject *self); |
| 1101 |
|
| 1102 |
static PyObject * |
| 1103 |
_elementtree_TreeBuilder_close(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 1104 |
{ |
| 1105 |
return _elementtree_TreeBuilder_close_impl((TreeBuilderObject *)self); |
| 1106 |
} |
| 1107 |
|
| 1108 |
PyDoc_STRVAR(_elementtree_TreeBuilder_start__doc__, |
| 1109 |
"start($self, tag, attrs, /)\n" |
| 1110 |
"--\n" |
| 1111 |
"\n"); |
| 1112 |
|
| 1113 |
#define _ELEMENTTREE_TREEBUILDER_START_METHODDEF \ |
| 1114 |
{"start", _PyCFunction_CAST(_elementtree_TreeBuilder_start), METH_FASTCALL, _elementtree_TreeBuilder_start__doc__}, |
| 1115 |
|
| 1116 |
static PyObject * |
| 1117 |
_elementtree_TreeBuilder_start_impl(TreeBuilderObject *self, PyObject *tag, |
| 1118 |
PyObject *attrs); |
| 1119 |
|
| 1120 |
static PyObject * |
| 1121 |
_elementtree_TreeBuilder_start(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
| 1122 |
{ |
| 1123 |
PyObject *return_value = NULL; |
| 1124 |
PyObject *tag; |
| 1125 |
PyObject *attrs; |
| 1126 |
|
| 1127 |
if (!_PyArg_CheckPositional("start", nargs, 2, 2)) { |
| 1128 |
goto exit; |
| 1129 |
} |
| 1130 |
tag = args[0]; |
| 1131 |
if (!PyDict_Check(args[1])) { |
| 1132 |
_PyArg_BadArgument("start", "argument 2", "dict", args[1]); |
| 1133 |
goto exit; |
| 1134 |
} |
| 1135 |
attrs = args[1]; |
| 1136 |
return_value = _elementtree_TreeBuilder_start_impl((TreeBuilderObject *)self, tag, attrs); |
| 1137 |
|
| 1138 |
exit: |
| 1139 |
return return_value; |
| 1140 |
} |
| 1141 |
|
| 1142 |
static int |
| 1143 |
_elementtree_XMLParser___init___impl(XMLParserObject *self, PyObject *target, |
| 1144 |
const char *encoding); |
| 1145 |
|
| 1146 |
static int |
| 1147 |
_elementtree_XMLParser___init__(PyObject *self, PyObject *args, PyObject *kwargs) |
| 1148 |
{ |
| 1149 |
int return_value = -1; |
| 1150 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 1151 |
|
| 1152 |
#define NUM_KEYWORDS 2 |
| 1153 |
static struct { |
| 1154 |
PyGC_Head _this_is_not_used; |
| 1155 |
PyObject_VAR_HEAD |
| 1156 |
Py_hash_t ob_hash; |
| 1157 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 1158 |
} _kwtuple = { |
| 1159 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 1160 |
.ob_hash = -1, |
| 1161 |
.ob_item = { &_Py_ID(target), &_Py_ID(encoding), }, |
| 1162 |
}; |
| 1163 |
#undef NUM_KEYWORDS |
| 1164 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 1165 |
|
| 1166 |
#else // !Py_BUILD_CORE |
| 1167 |
# define KWTUPLE NULL |
| 1168 |
#endif // !Py_BUILD_CORE |
| 1169 |
|
| 1170 |
static const char * const _keywords[] = {"target", "encoding", NULL}; |
| 1171 |
static _PyArg_Parser _parser = { |
| 1172 |
.keywords = _keywords, |
| 1173 |
.fname = "XMLParser", |
| 1174 |
.kwtuple = KWTUPLE, |
| 1175 |
}; |
| 1176 |
#undef KWTUPLE |
| 1177 |
PyObject *argsbuf[2]; |
| 1178 |
PyObject * const *fastargs; |
| 1179 |
Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
| 1180 |
Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0; |
| 1181 |
PyObject *target = Py_None; |
| 1182 |
const char *encoding = NULL; |
| 1183 |
|
| 1184 |
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, |
| 1185 |
/*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 1186 |
if (!fastargs) { |
| 1187 |
goto exit; |
| 1188 |
} |
| 1189 |
if (!noptargs) { |
| 1190 |
goto skip_optional_kwonly; |
| 1191 |
} |
| 1192 |
if (fastargs[0]) { |
| 1193 |
target = fastargs[0]; |
| 1194 |
if (!--noptargs) { |
| 1195 |
goto skip_optional_kwonly; |
| 1196 |
} |
| 1197 |
} |
| 1198 |
if (fastargs[1] == Py_None) { |
| 1199 |
encoding = NULL; |
| 1200 |
} |
| 1201 |
else if (PyUnicode_Check(fastargs[1])) { |
| 1202 |
Py_ssize_t encoding_length; |
| 1203 |
encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length); |
| 1204 |
if (encoding == NULL) { |
| 1205 |
goto exit; |
| 1206 |
} |
| 1207 |
if (strlen(encoding) != (size_t)encoding_length) { |
| 1208 |
PyErr_SetString(PyExc_ValueError, "embedded null character"); |
| 1209 |
goto exit; |
| 1210 |
} |
| 1211 |
} |
| 1212 |
else { |
| 1213 |
_PyArg_BadArgument("XMLParser", "argument 'encoding'", "str or None", fastargs[1]); |
| 1214 |
goto exit; |
| 1215 |
} |
| 1216 |
skip_optional_kwonly: |
| 1217 |
return_value = _elementtree_XMLParser___init___impl((XMLParserObject *)self, target, encoding); |
| 1218 |
|
| 1219 |
exit: |
| 1220 |
return return_value; |
| 1221 |
} |
| 1222 |
|
| 1223 |
PyDoc_STRVAR(_elementtree_XMLParser_close__doc__, |
| 1224 |
"close($self, /)\n" |
| 1225 |
"--\n" |
| 1226 |
"\n"); |
| 1227 |
|
| 1228 |
#define _ELEMENTTREE_XMLPARSER_CLOSE_METHODDEF \ |
| 1229 |
{"close", (PyCFunction)_elementtree_XMLParser_close, METH_NOARGS, _elementtree_XMLParser_close__doc__}, |
| 1230 |
|
| 1231 |
static PyObject * |
| 1232 |
_elementtree_XMLParser_close_impl(XMLParserObject *self); |
| 1233 |
|
| 1234 |
static PyObject * |
| 1235 |
_elementtree_XMLParser_close(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 1236 |
{ |
| 1237 |
return _elementtree_XMLParser_close_impl((XMLParserObject *)self); |
| 1238 |
} |
| 1239 |
|
| 1240 |
PyDoc_STRVAR(_elementtree_XMLParser_flush__doc__, |
| 1241 |
"flush($self, /)\n" |
| 1242 |
"--\n" |
| 1243 |
"\n"); |
| 1244 |
|
| 1245 |
#define _ELEMENTTREE_XMLPARSER_FLUSH_METHODDEF \ |
| 1246 |
{"flush", (PyCFunction)_elementtree_XMLParser_flush, METH_NOARGS, _elementtree_XMLParser_flush__doc__}, |
| 1247 |
|
| 1248 |
static PyObject * |
| 1249 |
_elementtree_XMLParser_flush_impl(XMLParserObject *self); |
| 1250 |
|
| 1251 |
static PyObject * |
| 1252 |
_elementtree_XMLParser_flush(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 1253 |
{ |
| 1254 |
return _elementtree_XMLParser_flush_impl((XMLParserObject *)self); |
| 1255 |
} |
| 1256 |
|
| 1257 |
PyDoc_STRVAR(_elementtree_XMLParser_feed__doc__, |
| 1258 |
"feed($self, data, /)\n" |
| 1259 |
"--\n" |
| 1260 |
"\n"); |
| 1261 |
|
| 1262 |
#define _ELEMENTTREE_XMLPARSER_FEED_METHODDEF \ |
| 1263 |
{"feed", (PyCFunction)_elementtree_XMLParser_feed, METH_O, _elementtree_XMLParser_feed__doc__}, |
| 1264 |
|
| 1265 |
static PyObject * |
| 1266 |
_elementtree_XMLParser_feed_impl(XMLParserObject *self, PyObject *data); |
| 1267 |
|
| 1268 |
static PyObject * |
| 1269 |
_elementtree_XMLParser_feed(PyObject *self, PyObject *data) |
| 1270 |
{ |
| 1271 |
PyObject *return_value = NULL; |
| 1272 |
|
| 1273 |
return_value = _elementtree_XMLParser_feed_impl((XMLParserObject *)self, data); |
| 1274 |
|
| 1275 |
return return_value; |
| 1276 |
} |
| 1277 |
|
| 1278 |
PyDoc_STRVAR(_elementtree_XMLParser__parse_whole__doc__, |
| 1279 |
"_parse_whole($self, file, /)\n" |
| 1280 |
"--\n" |
| 1281 |
"\n"); |
| 1282 |
|
| 1283 |
#define _ELEMENTTREE_XMLPARSER__PARSE_WHOLE_METHODDEF \ |
| 1284 |
{"_parse_whole", (PyCFunction)_elementtree_XMLParser__parse_whole, METH_O, _elementtree_XMLParser__parse_whole__doc__}, |
| 1285 |
|
| 1286 |
static PyObject * |
| 1287 |
_elementtree_XMLParser__parse_whole_impl(XMLParserObject *self, |
| 1288 |
PyObject *file); |
| 1289 |
|
| 1290 |
static PyObject * |
| 1291 |
_elementtree_XMLParser__parse_whole(PyObject *self, PyObject *file) |
| 1292 |
{ |
| 1293 |
PyObject *return_value = NULL; |
| 1294 |
|
| 1295 |
return_value = _elementtree_XMLParser__parse_whole_impl((XMLParserObject *)self, file); |
| 1296 |
|
| 1297 |
return return_value; |
| 1298 |
} |
| 1299 |
|
| 1300 |
PyDoc_STRVAR(_elementtree_XMLParser__setevents__doc__, |
| 1301 |
"_setevents($self, events_queue, events_to_report=None, /)\n" |
| 1302 |
"--\n" |
| 1303 |
"\n"); |
| 1304 |
|
| 1305 |
#define _ELEMENTTREE_XMLPARSER__SETEVENTS_METHODDEF \ |
| 1306 |
{"_setevents", _PyCFunction_CAST(_elementtree_XMLParser__setevents), METH_FASTCALL, _elementtree_XMLParser__setevents__doc__}, |
| 1307 |
|
| 1308 |
static PyObject * |
| 1309 |
_elementtree_XMLParser__setevents_impl(XMLParserObject *self, |
| 1310 |
PyObject *events_queue, |
| 1311 |
PyObject *events_to_report); |
| 1312 |
|
| 1313 |
static PyObject * |
| 1314 |
_elementtree_XMLParser__setevents(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
| 1315 |
{ |
| 1316 |
PyObject *return_value = NULL; |
| 1317 |
PyObject *events_queue; |
| 1318 |
PyObject *events_to_report = Py_None; |
| 1319 |
|
| 1320 |
if (!_PyArg_CheckPositional("_setevents", nargs, 1, 2)) { |
| 1321 |
goto exit; |
| 1322 |
} |
| 1323 |
events_queue = args[0]; |
| 1324 |
if (nargs < 2) { |
| 1325 |
goto skip_optional; |
| 1326 |
} |
| 1327 |
events_to_report = args[1]; |
| 1328 |
skip_optional: |
| 1329 |
return_value = _elementtree_XMLParser__setevents_impl((XMLParserObject *)self, events_queue, events_to_report); |
| 1330 |
|
| 1331 |
exit: |
| 1332 |
return return_value; |
| 1333 |
} |
| 1334 |
/*[clinic end generated code: output=c863ce16d8566291 input=a9049054013a1b77]*/ |