1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4
5 PyDoc_STRVAR(_elementtree_Element_append__doc__,
6 "append($self, subelement, /)\n"
7 "--\n"
8 "\n");
9
10 #define _ELEMENTTREE_ELEMENT_APPEND_METHODDEF \
11 {"append", (PyCFunction)_elementtree_Element_append, METH_O, _elementtree_Element_append__doc__},
12
13 static PyObject *
14 _elementtree_Element_append_impl(ElementObject *self, PyObject *subelement);
15
16 static PyObject *
_elementtree_Element_append(ElementObject * self,PyObject * arg)17 _elementtree_Element_append(ElementObject *self, PyObject *arg)
18 {
19 PyObject *return_value = NULL;
20 PyObject *subelement;
21
22 if (!PyObject_TypeCheck(arg, &Element_Type)) {
23 _PyArg_BadArgument("append", "argument", (&Element_Type)->tp_name, arg);
24 goto exit;
25 }
26 subelement = arg;
27 return_value = _elementtree_Element_append_impl(self, subelement);
28
29 exit:
30 return return_value;
31 }
32
33 PyDoc_STRVAR(_elementtree_Element_clear__doc__,
34 "clear($self, /)\n"
35 "--\n"
36 "\n");
37
38 #define _ELEMENTTREE_ELEMENT_CLEAR_METHODDEF \
39 {"clear", (PyCFunction)_elementtree_Element_clear, METH_NOARGS, _elementtree_Element_clear__doc__},
40
41 static PyObject *
42 _elementtree_Element_clear_impl(ElementObject *self);
43
44 static PyObject *
_elementtree_Element_clear(ElementObject * self,PyObject * Py_UNUSED (ignored))45 _elementtree_Element_clear(ElementObject *self, PyObject *Py_UNUSED(ignored))
46 {
47 return _elementtree_Element_clear_impl(self);
48 }
49
50 PyDoc_STRVAR(_elementtree_Element___copy____doc__,
51 "__copy__($self, /)\n"
52 "--\n"
53 "\n");
54
55 #define _ELEMENTTREE_ELEMENT___COPY___METHODDEF \
56 {"__copy__", (PyCFunction)_elementtree_Element___copy__, METH_NOARGS, _elementtree_Element___copy____doc__},
57
58 static PyObject *
59 _elementtree_Element___copy___impl(ElementObject *self);
60
61 static PyObject *
_elementtree_Element___copy__(ElementObject * self,PyObject * Py_UNUSED (ignored))62 _elementtree_Element___copy__(ElementObject *self, PyObject *Py_UNUSED(ignored))
63 {
64 return _elementtree_Element___copy___impl(self);
65 }
66
67 PyDoc_STRVAR(_elementtree_Element___deepcopy____doc__,
68 "__deepcopy__($self, memo, /)\n"
69 "--\n"
70 "\n");
71
72 #define _ELEMENTTREE_ELEMENT___DEEPCOPY___METHODDEF \
73 {"__deepcopy__", (PyCFunction)_elementtree_Element___deepcopy__, METH_O, _elementtree_Element___deepcopy____doc__},
74
75 static PyObject *
76 _elementtree_Element___deepcopy___impl(ElementObject *self, PyObject *memo);
77
78 static PyObject *
_elementtree_Element___deepcopy__(ElementObject * self,PyObject * arg)79 _elementtree_Element___deepcopy__(ElementObject *self, PyObject *arg)
80 {
81 PyObject *return_value = NULL;
82 PyObject *memo;
83
84 if (!PyDict_Check(arg)) {
85 _PyArg_BadArgument("__deepcopy__", "argument", "dict", arg);
86 goto exit;
87 }
88 memo = arg;
89 return_value = _elementtree_Element___deepcopy___impl(self, memo);
90
91 exit:
92 return return_value;
93 }
94
95 PyDoc_STRVAR(_elementtree_Element___sizeof____doc__,
96 "__sizeof__($self, /)\n"
97 "--\n"
98 "\n");
99
100 #define _ELEMENTTREE_ELEMENT___SIZEOF___METHODDEF \
101 {"__sizeof__", (PyCFunction)_elementtree_Element___sizeof__, METH_NOARGS, _elementtree_Element___sizeof____doc__},
102
103 static Py_ssize_t
104 _elementtree_Element___sizeof___impl(ElementObject *self);
105
106 static PyObject *
_elementtree_Element___sizeof__(ElementObject * self,PyObject * Py_UNUSED (ignored))107 _elementtree_Element___sizeof__(ElementObject *self, PyObject *Py_UNUSED(ignored))
108 {
109 PyObject *return_value = NULL;
110 Py_ssize_t _return_value;
111
112 _return_value = _elementtree_Element___sizeof___impl(self);
113 if ((_return_value == -1) && PyErr_Occurred()) {
114 goto exit;
115 }
116 return_value = PyLong_FromSsize_t(_return_value);
117
118 exit:
119 return return_value;
120 }
121
122 PyDoc_STRVAR(_elementtree_Element___getstate____doc__,
123 "__getstate__($self, /)\n"
124 "--\n"
125 "\n");
126
127 #define _ELEMENTTREE_ELEMENT___GETSTATE___METHODDEF \
128 {"__getstate__", (PyCFunction)_elementtree_Element___getstate__, METH_NOARGS, _elementtree_Element___getstate____doc__},
129
130 static PyObject *
131 _elementtree_Element___getstate___impl(ElementObject *self);
132
133 static PyObject *
_elementtree_Element___getstate__(ElementObject * self,PyObject * Py_UNUSED (ignored))134 _elementtree_Element___getstate__(ElementObject *self, PyObject *Py_UNUSED(ignored))
135 {
136 return _elementtree_Element___getstate___impl(self);
137 }
138
139 PyDoc_STRVAR(_elementtree_Element___setstate____doc__,
140 "__setstate__($self, state, /)\n"
141 "--\n"
142 "\n");
143
144 #define _ELEMENTTREE_ELEMENT___SETSTATE___METHODDEF \
145 {"__setstate__", (PyCFunction)_elementtree_Element___setstate__, METH_O, _elementtree_Element___setstate____doc__},
146
147 PyDoc_STRVAR(_elementtree_Element_extend__doc__,
148 "extend($self, elements, /)\n"
149 "--\n"
150 "\n");
151
152 #define _ELEMENTTREE_ELEMENT_EXTEND_METHODDEF \
153 {"extend", (PyCFunction)_elementtree_Element_extend, METH_O, _elementtree_Element_extend__doc__},
154
155 PyDoc_STRVAR(_elementtree_Element_find__doc__,
156 "find($self, /, path, namespaces=None)\n"
157 "--\n"
158 "\n");
159
160 #define _ELEMENTTREE_ELEMENT_FIND_METHODDEF \
161 {"find", (PyCFunction)(void(*)(void))_elementtree_Element_find, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_find__doc__},
162
163 static PyObject *
164 _elementtree_Element_find_impl(ElementObject *self, PyObject *path,
165 PyObject *namespaces);
166
167 static PyObject *
_elementtree_Element_find(ElementObject * self,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)168 _elementtree_Element_find(ElementObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
169 {
170 PyObject *return_value = NULL;
171 static const char * const _keywords[] = {"path", "namespaces", NULL};
172 static _PyArg_Parser _parser = {NULL, _keywords, "find", 0};
173 PyObject *argsbuf[2];
174 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
175 PyObject *path;
176 PyObject *namespaces = Py_None;
177
178 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
179 if (!args) {
180 goto exit;
181 }
182 path = args[0];
183 if (!noptargs) {
184 goto skip_optional_pos;
185 }
186 namespaces = args[1];
187 skip_optional_pos:
188 return_value = _elementtree_Element_find_impl(self, path, namespaces);
189
190 exit:
191 return return_value;
192 }
193
194 PyDoc_STRVAR(_elementtree_Element_findtext__doc__,
195 "findtext($self, /, path, default=None, namespaces=None)\n"
196 "--\n"
197 "\n");
198
199 #define _ELEMENTTREE_ELEMENT_FINDTEXT_METHODDEF \
200 {"findtext", (PyCFunction)(void(*)(void))_elementtree_Element_findtext, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_findtext__doc__},
201
202 static PyObject *
203 _elementtree_Element_findtext_impl(ElementObject *self, PyObject *path,
204 PyObject *default_value,
205 PyObject *namespaces);
206
207 static PyObject *
_elementtree_Element_findtext(ElementObject * self,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)208 _elementtree_Element_findtext(ElementObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
209 {
210 PyObject *return_value = NULL;
211 static const char * const _keywords[] = {"path", "default", "namespaces", NULL};
212 static _PyArg_Parser _parser = {NULL, _keywords, "findtext", 0};
213 PyObject *argsbuf[3];
214 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
215 PyObject *path;
216 PyObject *default_value = Py_None;
217 PyObject *namespaces = Py_None;
218
219 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
220 if (!args) {
221 goto exit;
222 }
223 path = args[0];
224 if (!noptargs) {
225 goto skip_optional_pos;
226 }
227 if (args[1]) {
228 default_value = args[1];
229 if (!--noptargs) {
230 goto skip_optional_pos;
231 }
232 }
233 namespaces = args[2];
234 skip_optional_pos:
235 return_value = _elementtree_Element_findtext_impl(self, path, default_value, namespaces);
236
237 exit:
238 return return_value;
239 }
240
241 PyDoc_STRVAR(_elementtree_Element_findall__doc__,
242 "findall($self, /, path, namespaces=None)\n"
243 "--\n"
244 "\n");
245
246 #define _ELEMENTTREE_ELEMENT_FINDALL_METHODDEF \
247 {"findall", (PyCFunction)(void(*)(void))_elementtree_Element_findall, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_findall__doc__},
248
249 static PyObject *
250 _elementtree_Element_findall_impl(ElementObject *self, PyObject *path,
251 PyObject *namespaces);
252
253 static PyObject *
_elementtree_Element_findall(ElementObject * self,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)254 _elementtree_Element_findall(ElementObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
255 {
256 PyObject *return_value = NULL;
257 static const char * const _keywords[] = {"path", "namespaces", NULL};
258 static _PyArg_Parser _parser = {NULL, _keywords, "findall", 0};
259 PyObject *argsbuf[2];
260 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
261 PyObject *path;
262 PyObject *namespaces = Py_None;
263
264 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
265 if (!args) {
266 goto exit;
267 }
268 path = args[0];
269 if (!noptargs) {
270 goto skip_optional_pos;
271 }
272 namespaces = args[1];
273 skip_optional_pos:
274 return_value = _elementtree_Element_findall_impl(self, path, namespaces);
275
276 exit:
277 return return_value;
278 }
279
280 PyDoc_STRVAR(_elementtree_Element_iterfind__doc__,
281 "iterfind($self, /, path, namespaces=None)\n"
282 "--\n"
283 "\n");
284
285 #define _ELEMENTTREE_ELEMENT_ITERFIND_METHODDEF \
286 {"iterfind", (PyCFunction)(void(*)(void))_elementtree_Element_iterfind, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_iterfind__doc__},
287
288 static PyObject *
289 _elementtree_Element_iterfind_impl(ElementObject *self, PyObject *path,
290 PyObject *namespaces);
291
292 static PyObject *
_elementtree_Element_iterfind(ElementObject * self,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)293 _elementtree_Element_iterfind(ElementObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
294 {
295 PyObject *return_value = NULL;
296 static const char * const _keywords[] = {"path", "namespaces", NULL};
297 static _PyArg_Parser _parser = {NULL, _keywords, "iterfind", 0};
298 PyObject *argsbuf[2];
299 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
300 PyObject *path;
301 PyObject *namespaces = Py_None;
302
303 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
304 if (!args) {
305 goto exit;
306 }
307 path = args[0];
308 if (!noptargs) {
309 goto skip_optional_pos;
310 }
311 namespaces = args[1];
312 skip_optional_pos:
313 return_value = _elementtree_Element_iterfind_impl(self, path, namespaces);
314
315 exit:
316 return return_value;
317 }
318
319 PyDoc_STRVAR(_elementtree_Element_get__doc__,
320 "get($self, /, key, default=None)\n"
321 "--\n"
322 "\n");
323
324 #define _ELEMENTTREE_ELEMENT_GET_METHODDEF \
325 {"get", (PyCFunction)(void(*)(void))_elementtree_Element_get, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_get__doc__},
326
327 static PyObject *
328 _elementtree_Element_get_impl(ElementObject *self, PyObject *key,
329 PyObject *default_value);
330
331 static PyObject *
_elementtree_Element_get(ElementObject * self,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)332 _elementtree_Element_get(ElementObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
333 {
334 PyObject *return_value = NULL;
335 static const char * const _keywords[] = {"key", "default", NULL};
336 static _PyArg_Parser _parser = {NULL, _keywords, "get", 0};
337 PyObject *argsbuf[2];
338 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
339 PyObject *key;
340 PyObject *default_value = Py_None;
341
342 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
343 if (!args) {
344 goto exit;
345 }
346 key = args[0];
347 if (!noptargs) {
348 goto skip_optional_pos;
349 }
350 default_value = args[1];
351 skip_optional_pos:
352 return_value = _elementtree_Element_get_impl(self, key, default_value);
353
354 exit:
355 return return_value;
356 }
357
358 PyDoc_STRVAR(_elementtree_Element_iter__doc__,
359 "iter($self, /, tag=None)\n"
360 "--\n"
361 "\n");
362
363 #define _ELEMENTTREE_ELEMENT_ITER_METHODDEF \
364 {"iter", (PyCFunction)(void(*)(void))_elementtree_Element_iter, METH_FASTCALL|METH_KEYWORDS, _elementtree_Element_iter__doc__},
365
366 static PyObject *
367 _elementtree_Element_iter_impl(ElementObject *self, PyObject *tag);
368
369 static PyObject *
_elementtree_Element_iter(ElementObject * self,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)370 _elementtree_Element_iter(ElementObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
371 {
372 PyObject *return_value = NULL;
373 static const char * const _keywords[] = {"tag", NULL};
374 static _PyArg_Parser _parser = {NULL, _keywords, "iter", 0};
375 PyObject *argsbuf[1];
376 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
377 PyObject *tag = Py_None;
378
379 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
380 if (!args) {
381 goto exit;
382 }
383 if (!noptargs) {
384 goto skip_optional_pos;
385 }
386 tag = args[0];
387 skip_optional_pos:
388 return_value = _elementtree_Element_iter_impl(self, tag);
389
390 exit:
391 return return_value;
392 }
393
394 PyDoc_STRVAR(_elementtree_Element_itertext__doc__,
395 "itertext($self, /)\n"
396 "--\n"
397 "\n");
398
399 #define _ELEMENTTREE_ELEMENT_ITERTEXT_METHODDEF \
400 {"itertext", (PyCFunction)_elementtree_Element_itertext, METH_NOARGS, _elementtree_Element_itertext__doc__},
401
402 static PyObject *
403 _elementtree_Element_itertext_impl(ElementObject *self);
404
405 static PyObject *
_elementtree_Element_itertext(ElementObject * self,PyObject * Py_UNUSED (ignored))406 _elementtree_Element_itertext(ElementObject *self, PyObject *Py_UNUSED(ignored))
407 {
408 return _elementtree_Element_itertext_impl(self);
409 }
410
411 PyDoc_STRVAR(_elementtree_Element_insert__doc__,
412 "insert($self, index, subelement, /)\n"
413 "--\n"
414 "\n");
415
416 #define _ELEMENTTREE_ELEMENT_INSERT_METHODDEF \
417 {"insert", (PyCFunction)(void(*)(void))_elementtree_Element_insert, METH_FASTCALL, _elementtree_Element_insert__doc__},
418
419 static PyObject *
420 _elementtree_Element_insert_impl(ElementObject *self, Py_ssize_t index,
421 PyObject *subelement);
422
423 static PyObject *
_elementtree_Element_insert(ElementObject * self,PyObject * const * args,Py_ssize_t nargs)424 _elementtree_Element_insert(ElementObject *self, PyObject *const *args, Py_ssize_t nargs)
425 {
426 PyObject *return_value = NULL;
427 Py_ssize_t index;
428 PyObject *subelement;
429
430 if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) {
431 goto exit;
432 }
433 {
434 Py_ssize_t ival = -1;
435 PyObject *iobj = _PyNumber_Index(args[0]);
436 if (iobj != NULL) {
437 ival = PyLong_AsSsize_t(iobj);
438 Py_DECREF(iobj);
439 }
440 if (ival == -1 && PyErr_Occurred()) {
441 goto exit;
442 }
443 index = ival;
444 }
445 if (!PyObject_TypeCheck(args[1], &Element_Type)) {
446 _PyArg_BadArgument("insert", "argument 2", (&Element_Type)->tp_name, args[1]);
447 goto exit;
448 }
449 subelement = args[1];
450 return_value = _elementtree_Element_insert_impl(self, index, subelement);
451
452 exit:
453 return return_value;
454 }
455
456 PyDoc_STRVAR(_elementtree_Element_items__doc__,
457 "items($self, /)\n"
458 "--\n"
459 "\n");
460
461 #define _ELEMENTTREE_ELEMENT_ITEMS_METHODDEF \
462 {"items", (PyCFunction)_elementtree_Element_items, METH_NOARGS, _elementtree_Element_items__doc__},
463
464 static PyObject *
465 _elementtree_Element_items_impl(ElementObject *self);
466
467 static PyObject *
_elementtree_Element_items(ElementObject * self,PyObject * Py_UNUSED (ignored))468 _elementtree_Element_items(ElementObject *self, PyObject *Py_UNUSED(ignored))
469 {
470 return _elementtree_Element_items_impl(self);
471 }
472
473 PyDoc_STRVAR(_elementtree_Element_keys__doc__,
474 "keys($self, /)\n"
475 "--\n"
476 "\n");
477
478 #define _ELEMENTTREE_ELEMENT_KEYS_METHODDEF \
479 {"keys", (PyCFunction)_elementtree_Element_keys, METH_NOARGS, _elementtree_Element_keys__doc__},
480
481 static PyObject *
482 _elementtree_Element_keys_impl(ElementObject *self);
483
484 static PyObject *
_elementtree_Element_keys(ElementObject * self,PyObject * Py_UNUSED (ignored))485 _elementtree_Element_keys(ElementObject *self, PyObject *Py_UNUSED(ignored))
486 {
487 return _elementtree_Element_keys_impl(self);
488 }
489
490 PyDoc_STRVAR(_elementtree_Element_makeelement__doc__,
491 "makeelement($self, tag, attrib, /)\n"
492 "--\n"
493 "\n");
494
495 #define _ELEMENTTREE_ELEMENT_MAKEELEMENT_METHODDEF \
496 {"makeelement", (PyCFunction)(void(*)(void))_elementtree_Element_makeelement, METH_FASTCALL, _elementtree_Element_makeelement__doc__},
497
498 static PyObject *
499 _elementtree_Element_makeelement_impl(ElementObject *self, PyObject *tag,
500 PyObject *attrib);
501
502 static PyObject *
_elementtree_Element_makeelement(ElementObject * self,PyObject * const * args,Py_ssize_t nargs)503 _elementtree_Element_makeelement(ElementObject *self, PyObject *const *args, Py_ssize_t nargs)
504 {
505 PyObject *return_value = NULL;
506 PyObject *tag;
507 PyObject *attrib;
508
509 if (!_PyArg_CheckPositional("makeelement", nargs, 2, 2)) {
510 goto exit;
511 }
512 tag = args[0];
513 if (!PyDict_Check(args[1])) {
514 _PyArg_BadArgument("makeelement", "argument 2", "dict", args[1]);
515 goto exit;
516 }
517 attrib = args[1];
518 return_value = _elementtree_Element_makeelement_impl(self, tag, attrib);
519
520 exit:
521 return return_value;
522 }
523
524 PyDoc_STRVAR(_elementtree_Element_remove__doc__,
525 "remove($self, subelement, /)\n"
526 "--\n"
527 "\n");
528
529 #define _ELEMENTTREE_ELEMENT_REMOVE_METHODDEF \
530 {"remove", (PyCFunction)_elementtree_Element_remove, METH_O, _elementtree_Element_remove__doc__},
531
532 static PyObject *
533 _elementtree_Element_remove_impl(ElementObject *self, PyObject *subelement);
534
535 static PyObject *
_elementtree_Element_remove(ElementObject * self,PyObject * arg)536 _elementtree_Element_remove(ElementObject *self, PyObject *arg)
537 {
538 PyObject *return_value = NULL;
539 PyObject *subelement;
540
541 if (!PyObject_TypeCheck(arg, &Element_Type)) {
542 _PyArg_BadArgument("remove", "argument", (&Element_Type)->tp_name, arg);
543 goto exit;
544 }
545 subelement = arg;
546 return_value = _elementtree_Element_remove_impl(self, subelement);
547
548 exit:
549 return return_value;
550 }
551
552 PyDoc_STRVAR(_elementtree_Element_set__doc__,
553 "set($self, key, value, /)\n"
554 "--\n"
555 "\n");
556
557 #define _ELEMENTTREE_ELEMENT_SET_METHODDEF \
558 {"set", (PyCFunction)(void(*)(void))_elementtree_Element_set, METH_FASTCALL, _elementtree_Element_set__doc__},
559
560 static PyObject *
561 _elementtree_Element_set_impl(ElementObject *self, PyObject *key,
562 PyObject *value);
563
564 static PyObject *
_elementtree_Element_set(ElementObject * self,PyObject * const * args,Py_ssize_t nargs)565 _elementtree_Element_set(ElementObject *self, PyObject *const *args, Py_ssize_t nargs)
566 {
567 PyObject *return_value = NULL;
568 PyObject *key;
569 PyObject *value;
570
571 if (!_PyArg_CheckPositional("set", nargs, 2, 2)) {
572 goto exit;
573 }
574 key = args[0];
575 value = args[1];
576 return_value = _elementtree_Element_set_impl(self, key, value);
577
578 exit:
579 return return_value;
580 }
581
582 static int
583 _elementtree_TreeBuilder___init___impl(TreeBuilderObject *self,
584 PyObject *element_factory,
585 PyObject *comment_factory,
586 PyObject *pi_factory,
587 int insert_comments, int insert_pis);
588
589 static int
_elementtree_TreeBuilder___init__(PyObject * self,PyObject * args,PyObject * kwargs)590 _elementtree_TreeBuilder___init__(PyObject *self, PyObject *args, PyObject *kwargs)
591 {
592 int return_value = -1;
593 static const char * const _keywords[] = {"element_factory", "comment_factory", "pi_factory", "insert_comments", "insert_pis", NULL};
594 static _PyArg_Parser _parser = {NULL, _keywords, "TreeBuilder", 0};
595 PyObject *argsbuf[5];
596 PyObject * const *fastargs;
597 Py_ssize_t nargs = PyTuple_GET_SIZE(args);
598 Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0;
599 PyObject *element_factory = Py_None;
600 PyObject *comment_factory = Py_None;
601 PyObject *pi_factory = Py_None;
602 int insert_comments = 0;
603 int insert_pis = 0;
604
605 fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 1, 0, argsbuf);
606 if (!fastargs) {
607 goto exit;
608 }
609 if (!noptargs) {
610 goto skip_optional_pos;
611 }
612 if (fastargs[0]) {
613 element_factory = fastargs[0];
614 if (!--noptargs) {
615 goto skip_optional_pos;
616 }
617 }
618 skip_optional_pos:
619 if (!noptargs) {
620 goto skip_optional_kwonly;
621 }
622 if (fastargs[1]) {
623 comment_factory = fastargs[1];
624 if (!--noptargs) {
625 goto skip_optional_kwonly;
626 }
627 }
628 if (fastargs[2]) {
629 pi_factory = fastargs[2];
630 if (!--noptargs) {
631 goto skip_optional_kwonly;
632 }
633 }
634 if (fastargs[3]) {
635 insert_comments = PyObject_IsTrue(fastargs[3]);
636 if (insert_comments < 0) {
637 goto exit;
638 }
639 if (!--noptargs) {
640 goto skip_optional_kwonly;
641 }
642 }
643 insert_pis = PyObject_IsTrue(fastargs[4]);
644 if (insert_pis < 0) {
645 goto exit;
646 }
647 skip_optional_kwonly:
648 return_value = _elementtree_TreeBuilder___init___impl((TreeBuilderObject *)self, element_factory, comment_factory, pi_factory, insert_comments, insert_pis);
649
650 exit:
651 return return_value;
652 }
653
654 PyDoc_STRVAR(_elementtree__set_factories__doc__,
655 "_set_factories($module, comment_factory, pi_factory, /)\n"
656 "--\n"
657 "\n"
658 "Change the factories used to create comments and processing instructions.\n"
659 "\n"
660 "For internal use only.");
661
662 #define _ELEMENTTREE__SET_FACTORIES_METHODDEF \
663 {"_set_factories", (PyCFunction)(void(*)(void))_elementtree__set_factories, METH_FASTCALL, _elementtree__set_factories__doc__},
664
665 static PyObject *
666 _elementtree__set_factories_impl(PyObject *module, PyObject *comment_factory,
667 PyObject *pi_factory);
668
669 static PyObject *
_elementtree__set_factories(PyObject * module,PyObject * const * args,Py_ssize_t nargs)670 _elementtree__set_factories(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
671 {
672 PyObject *return_value = NULL;
673 PyObject *comment_factory;
674 PyObject *pi_factory;
675
676 if (!_PyArg_CheckPositional("_set_factories", nargs, 2, 2)) {
677 goto exit;
678 }
679 comment_factory = args[0];
680 pi_factory = args[1];
681 return_value = _elementtree__set_factories_impl(module, comment_factory, pi_factory);
682
683 exit:
684 return return_value;
685 }
686
687 PyDoc_STRVAR(_elementtree_TreeBuilder_data__doc__,
688 "data($self, data, /)\n"
689 "--\n"
690 "\n");
691
692 #define _ELEMENTTREE_TREEBUILDER_DATA_METHODDEF \
693 {"data", (PyCFunction)_elementtree_TreeBuilder_data, METH_O, _elementtree_TreeBuilder_data__doc__},
694
695 PyDoc_STRVAR(_elementtree_TreeBuilder_end__doc__,
696 "end($self, tag, /)\n"
697 "--\n"
698 "\n");
699
700 #define _ELEMENTTREE_TREEBUILDER_END_METHODDEF \
701 {"end", (PyCFunction)_elementtree_TreeBuilder_end, METH_O, _elementtree_TreeBuilder_end__doc__},
702
703 PyDoc_STRVAR(_elementtree_TreeBuilder_comment__doc__,
704 "comment($self, text, /)\n"
705 "--\n"
706 "\n");
707
708 #define _ELEMENTTREE_TREEBUILDER_COMMENT_METHODDEF \
709 {"comment", (PyCFunction)_elementtree_TreeBuilder_comment, METH_O, _elementtree_TreeBuilder_comment__doc__},
710
711 PyDoc_STRVAR(_elementtree_TreeBuilder_pi__doc__,
712 "pi($self, target, text=None, /)\n"
713 "--\n"
714 "\n");
715
716 #define _ELEMENTTREE_TREEBUILDER_PI_METHODDEF \
717 {"pi", (PyCFunction)(void(*)(void))_elementtree_TreeBuilder_pi, METH_FASTCALL, _elementtree_TreeBuilder_pi__doc__},
718
719 static PyObject *
720 _elementtree_TreeBuilder_pi_impl(TreeBuilderObject *self, PyObject *target,
721 PyObject *text);
722
723 static PyObject *
_elementtree_TreeBuilder_pi(TreeBuilderObject * self,PyObject * const * args,Py_ssize_t nargs)724 _elementtree_TreeBuilder_pi(TreeBuilderObject *self, PyObject *const *args, Py_ssize_t nargs)
725 {
726 PyObject *return_value = NULL;
727 PyObject *target;
728 PyObject *text = Py_None;
729
730 if (!_PyArg_CheckPositional("pi", nargs, 1, 2)) {
731 goto exit;
732 }
733 target = args[0];
734 if (nargs < 2) {
735 goto skip_optional;
736 }
737 text = args[1];
738 skip_optional:
739 return_value = _elementtree_TreeBuilder_pi_impl(self, target, text);
740
741 exit:
742 return return_value;
743 }
744
745 PyDoc_STRVAR(_elementtree_TreeBuilder_close__doc__,
746 "close($self, /)\n"
747 "--\n"
748 "\n");
749
750 #define _ELEMENTTREE_TREEBUILDER_CLOSE_METHODDEF \
751 {"close", (PyCFunction)_elementtree_TreeBuilder_close, METH_NOARGS, _elementtree_TreeBuilder_close__doc__},
752
753 static PyObject *
754 _elementtree_TreeBuilder_close_impl(TreeBuilderObject *self);
755
756 static PyObject *
_elementtree_TreeBuilder_close(TreeBuilderObject * self,PyObject * Py_UNUSED (ignored))757 _elementtree_TreeBuilder_close(TreeBuilderObject *self, PyObject *Py_UNUSED(ignored))
758 {
759 return _elementtree_TreeBuilder_close_impl(self);
760 }
761
762 PyDoc_STRVAR(_elementtree_TreeBuilder_start__doc__,
763 "start($self, tag, attrs, /)\n"
764 "--\n"
765 "\n");
766
767 #define _ELEMENTTREE_TREEBUILDER_START_METHODDEF \
768 {"start", (PyCFunction)(void(*)(void))_elementtree_TreeBuilder_start, METH_FASTCALL, _elementtree_TreeBuilder_start__doc__},
769
770 static PyObject *
771 _elementtree_TreeBuilder_start_impl(TreeBuilderObject *self, PyObject *tag,
772 PyObject *attrs);
773
774 static PyObject *
_elementtree_TreeBuilder_start(TreeBuilderObject * self,PyObject * const * args,Py_ssize_t nargs)775 _elementtree_TreeBuilder_start(TreeBuilderObject *self, PyObject *const *args, Py_ssize_t nargs)
776 {
777 PyObject *return_value = NULL;
778 PyObject *tag;
779 PyObject *attrs;
780
781 if (!_PyArg_CheckPositional("start", nargs, 2, 2)) {
782 goto exit;
783 }
784 tag = args[0];
785 if (!PyDict_Check(args[1])) {
786 _PyArg_BadArgument("start", "argument 2", "dict", args[1]);
787 goto exit;
788 }
789 attrs = args[1];
790 return_value = _elementtree_TreeBuilder_start_impl(self, tag, attrs);
791
792 exit:
793 return return_value;
794 }
795
796 static int
797 _elementtree_XMLParser___init___impl(XMLParserObject *self, PyObject *target,
798 const char *encoding);
799
800 static int
_elementtree_XMLParser___init__(PyObject * self,PyObject * args,PyObject * kwargs)801 _elementtree_XMLParser___init__(PyObject *self, PyObject *args, PyObject *kwargs)
802 {
803 int return_value = -1;
804 static const char * const _keywords[] = {"target", "encoding", NULL};
805 static _PyArg_Parser _parser = {NULL, _keywords, "XMLParser", 0};
806 PyObject *argsbuf[2];
807 PyObject * const *fastargs;
808 Py_ssize_t nargs = PyTuple_GET_SIZE(args);
809 Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0;
810 PyObject *target = NULL;
811 const char *encoding = NULL;
812
813 fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 0, 0, argsbuf);
814 if (!fastargs) {
815 goto exit;
816 }
817 if (!noptargs) {
818 goto skip_optional_kwonly;
819 }
820 if (fastargs[0]) {
821 target = fastargs[0];
822 if (!--noptargs) {
823 goto skip_optional_kwonly;
824 }
825 }
826 if (fastargs[1] == Py_None) {
827 encoding = NULL;
828 }
829 else if (PyUnicode_Check(fastargs[1])) {
830 Py_ssize_t encoding_length;
831 encoding = PyUnicode_AsUTF8AndSize(fastargs[1], &encoding_length);
832 if (encoding == NULL) {
833 goto exit;
834 }
835 if (strlen(encoding) != (size_t)encoding_length) {
836 PyErr_SetString(PyExc_ValueError, "embedded null character");
837 goto exit;
838 }
839 }
840 else {
841 _PyArg_BadArgument("XMLParser", "argument 'encoding'", "str or None", fastargs[1]);
842 goto exit;
843 }
844 skip_optional_kwonly:
845 return_value = _elementtree_XMLParser___init___impl((XMLParserObject *)self, target, encoding);
846
847 exit:
848 return return_value;
849 }
850
851 PyDoc_STRVAR(_elementtree_XMLParser_close__doc__,
852 "close($self, /)\n"
853 "--\n"
854 "\n");
855
856 #define _ELEMENTTREE_XMLPARSER_CLOSE_METHODDEF \
857 {"close", (PyCFunction)_elementtree_XMLParser_close, METH_NOARGS, _elementtree_XMLParser_close__doc__},
858
859 static PyObject *
860 _elementtree_XMLParser_close_impl(XMLParserObject *self);
861
862 static PyObject *
_elementtree_XMLParser_close(XMLParserObject * self,PyObject * Py_UNUSED (ignored))863 _elementtree_XMLParser_close(XMLParserObject *self, PyObject *Py_UNUSED(ignored))
864 {
865 return _elementtree_XMLParser_close_impl(self);
866 }
867
868 PyDoc_STRVAR(_elementtree_XMLParser_feed__doc__,
869 "feed($self, data, /)\n"
870 "--\n"
871 "\n");
872
873 #define _ELEMENTTREE_XMLPARSER_FEED_METHODDEF \
874 {"feed", (PyCFunction)_elementtree_XMLParser_feed, METH_O, _elementtree_XMLParser_feed__doc__},
875
876 PyDoc_STRVAR(_elementtree_XMLParser__parse_whole__doc__,
877 "_parse_whole($self, file, /)\n"
878 "--\n"
879 "\n");
880
881 #define _ELEMENTTREE_XMLPARSER__PARSE_WHOLE_METHODDEF \
882 {"_parse_whole", (PyCFunction)_elementtree_XMLParser__parse_whole, METH_O, _elementtree_XMLParser__parse_whole__doc__},
883
884 PyDoc_STRVAR(_elementtree_XMLParser__setevents__doc__,
885 "_setevents($self, events_queue, events_to_report=None, /)\n"
886 "--\n"
887 "\n");
888
889 #define _ELEMENTTREE_XMLPARSER__SETEVENTS_METHODDEF \
890 {"_setevents", (PyCFunction)(void(*)(void))_elementtree_XMLParser__setevents, METH_FASTCALL, _elementtree_XMLParser__setevents__doc__},
891
892 static PyObject *
893 _elementtree_XMLParser__setevents_impl(XMLParserObject *self,
894 PyObject *events_queue,
895 PyObject *events_to_report);
896
897 static PyObject *
_elementtree_XMLParser__setevents(XMLParserObject * self,PyObject * const * args,Py_ssize_t nargs)898 _elementtree_XMLParser__setevents(XMLParserObject *self, PyObject *const *args, Py_ssize_t nargs)
899 {
900 PyObject *return_value = NULL;
901 PyObject *events_queue;
902 PyObject *events_to_report = Py_None;
903
904 if (!_PyArg_CheckPositional("_setevents", nargs, 1, 2)) {
905 goto exit;
906 }
907 events_queue = args[0];
908 if (nargs < 2) {
909 goto skip_optional;
910 }
911 events_to_report = args[1];
912 skip_optional:
913 return_value = _elementtree_XMLParser__setevents_impl(self, events_queue, events_to_report);
914
915 exit:
916 return return_value;
917 }
918 /*[clinic end generated code: output=1385b5e5688f3614 input=a9049054013a1b77]*/
919