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