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