Debian Codegraph @

Modules/clinic/pyexpat.c.h

raw
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_long.h" // _PyLong_UnsignedLongLong_Converter()
10 #include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
11
12 PyDoc_STRVAR(pyexpat_xmlparser_SetReparseDeferralEnabled__doc__,
13 "SetReparseDeferralEnabled($self, enabled, /)\n"
14 "--\n"
15 "\n"
16 "Enable/Disable reparse deferral; enabled by default with Expat >=2.6.0.");
17
18 #define PYEXPAT_XMLPARSER_SETREPARSEDEFERRALENABLED_METHODDEF \
19 {"SetReparseDeferralEnabled", (PyCFunction)pyexpat_xmlparser_SetReparseDeferralEnabled, METH_O, pyexpat_xmlparser_SetReparseDeferralEnabled__doc__},
20
21 static PyObject *
22 pyexpat_xmlparser_SetReparseDeferralEnabled_impl(xmlparseobject *self,
23 int enabled);
24
25 static PyObject *
26 pyexpat_xmlparser_SetReparseDeferralEnabled(xmlparseobject *self, PyObject *arg)
27 {
28 PyObject *return_value = NULL;
29 int enabled;
30
31 enabled = PyObject_IsTrue(arg);
32 if (enabled < 0) {
33 goto exit;
34 }
35 return_value = pyexpat_xmlparser_SetReparseDeferralEnabled_impl(self, enabled);
36
37 exit:
38 return return_value;
39 }
40
41 PyDoc_STRVAR(pyexpat_xmlparser_GetReparseDeferralEnabled__doc__,
42 "GetReparseDeferralEnabled($self, /)\n"
43 "--\n"
44 "\n"
45 "Retrieve reparse deferral enabled status; always returns false with Expat <2.6.0.");
46
47 #define PYEXPAT_XMLPARSER_GETREPARSEDEFERRALENABLED_METHODDEF \
48 {"GetReparseDeferralEnabled", (PyCFunction)pyexpat_xmlparser_GetReparseDeferralEnabled, METH_NOARGS, pyexpat_xmlparser_GetReparseDeferralEnabled__doc__},
49
50 static PyObject *
51 pyexpat_xmlparser_GetReparseDeferralEnabled_impl(xmlparseobject *self);
52
53 static PyObject *
54 pyexpat_xmlparser_GetReparseDeferralEnabled(xmlparseobject *self, PyObject *Py_UNUSED(ignored))
55 {
56 return pyexpat_xmlparser_GetReparseDeferralEnabled_impl(self);
57 }
58
59 PyDoc_STRVAR(pyexpat_xmlparser_Parse__doc__,
60 "Parse($self, data, isfinal=False, /)\n"
61 "--\n"
62 "\n"
63 "Parse XML data.\n"
64 "\n"
65 "`isfinal\' should be true at end of input.");
66
67 #define PYEXPAT_XMLPARSER_PARSE_METHODDEF \
68 {"Parse", _PyCFunction_CAST(pyexpat_xmlparser_Parse), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_Parse__doc__},
69
70 static PyObject *
71 pyexpat_xmlparser_Parse_impl(xmlparseobject *self, PyTypeObject *cls,
72 PyObject *data, int isfinal);
73
74 static PyObject *
75 pyexpat_xmlparser_Parse(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
76 {
77 PyObject *return_value = NULL;
78 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
79 # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
80 #else
81 # define KWTUPLE NULL
82 #endif
83
84 static const char * const _keywords[] = {"", "", NULL};
85 static _PyArg_Parser _parser = {
86 .keywords = _keywords,
87 .fname = "Parse",
88 .kwtuple = KWTUPLE,
89 };
90 #undef KWTUPLE
91 PyObject *argsbuf[2];
92 PyObject *data;
93 int isfinal = 0;
94
95 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
96 if (!args) {
97 goto exit;
98 }
99 data = args[0];
100 if (nargs < 2) {
101 goto skip_optional_posonly;
102 }
103 isfinal = PyObject_IsTrue(args[1]);
104 if (isfinal < 0) {
105 goto exit;
106 }
107 skip_optional_posonly:
108 return_value = pyexpat_xmlparser_Parse_impl(self, cls, data, isfinal);
109
110 exit:
111 return return_value;
112 }
113
114 PyDoc_STRVAR(pyexpat_xmlparser_ParseFile__doc__,
115 "ParseFile($self, file, /)\n"
116 "--\n"
117 "\n"
118 "Parse XML data from file-like object.");
119
120 #define PYEXPAT_XMLPARSER_PARSEFILE_METHODDEF \
121 {"ParseFile", _PyCFunction_CAST(pyexpat_xmlparser_ParseFile), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_ParseFile__doc__},
122
123 static PyObject *
124 pyexpat_xmlparser_ParseFile_impl(xmlparseobject *self, PyTypeObject *cls,
125 PyObject *file);
126
127 static PyObject *
128 pyexpat_xmlparser_ParseFile(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
129 {
130 PyObject *return_value = NULL;
131 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
132 # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
133 #else
134 # define KWTUPLE NULL
135 #endif
136
137 static const char * const _keywords[] = {"", NULL};
138 static _PyArg_Parser _parser = {
139 .keywords = _keywords,
140 .fname = "ParseFile",
141 .kwtuple = KWTUPLE,
142 };
143 #undef KWTUPLE
144 PyObject *argsbuf[1];
145 PyObject *file;
146
147 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
148 if (!args) {
149 goto exit;
150 }
151 file = args[0];
152 return_value = pyexpat_xmlparser_ParseFile_impl(self, cls, file);
153
154 exit:
155 return return_value;
156 }
157
158 PyDoc_STRVAR(pyexpat_xmlparser_SetBase__doc__,
159 "SetBase($self, base, /)\n"
160 "--\n"
161 "\n"
162 "Set the base URL for the parser.");
163
164 #define PYEXPAT_XMLPARSER_SETBASE_METHODDEF \
165 {"SetBase", (PyCFunction)pyexpat_xmlparser_SetBase, METH_O, pyexpat_xmlparser_SetBase__doc__},
166
167 static PyObject *
168 pyexpat_xmlparser_SetBase_impl(xmlparseobject *self, const char *base);
169
170 static PyObject *
171 pyexpat_xmlparser_SetBase(xmlparseobject *self, PyObject *arg)
172 {
173 PyObject *return_value = NULL;
174 const char *base;
175
176 if (!PyUnicode_Check(arg)) {
177 _PyArg_BadArgument("SetBase", "argument", "str", arg);
178 goto exit;
179 }
180 Py_ssize_t base_length;
181 base = PyUnicode_AsUTF8AndSize(arg, &base_length);
182 if (base == NULL) {
183 goto exit;
184 }
185 if (strlen(base) != (size_t)base_length) {
186 PyErr_SetString(PyExc_ValueError, "embedded null character");
187 goto exit;
188 }
189 return_value = pyexpat_xmlparser_SetBase_impl(self, base);
190
191 exit:
192 return return_value;
193 }
194
195 PyDoc_STRVAR(pyexpat_xmlparser_GetBase__doc__,
196 "GetBase($self, /)\n"
197 "--\n"
198 "\n"
199 "Return base URL string for the parser.");
200
201 #define PYEXPAT_XMLPARSER_GETBASE_METHODDEF \
202 {"GetBase", (PyCFunction)pyexpat_xmlparser_GetBase, METH_NOARGS, pyexpat_xmlparser_GetBase__doc__},
203
204 static PyObject *
205 pyexpat_xmlparser_GetBase_impl(xmlparseobject *self);
206
207 static PyObject *
208 pyexpat_xmlparser_GetBase(xmlparseobject *self, PyObject *Py_UNUSED(ignored))
209 {
210 return pyexpat_xmlparser_GetBase_impl(self);
211 }
212
213 PyDoc_STRVAR(pyexpat_xmlparser_GetInputContext__doc__,
214 "GetInputContext($self, /)\n"
215 "--\n"
216 "\n"
217 "Return the untranslated text of the input that caused the current event.\n"
218 "\n"
219 "If the event was generated by a large amount of text (such as a start tag\n"
220 "for an element with many attributes), not all of the text may be available.");
221
222 #define PYEXPAT_XMLPARSER_GETINPUTCONTEXT_METHODDEF \
223 {"GetInputContext", (PyCFunction)pyexpat_xmlparser_GetInputContext, METH_NOARGS, pyexpat_xmlparser_GetInputContext__doc__},
224
225 static PyObject *
226 pyexpat_xmlparser_GetInputContext_impl(xmlparseobject *self);
227
228 static PyObject *
229 pyexpat_xmlparser_GetInputContext(xmlparseobject *self, PyObject *Py_UNUSED(ignored))
230 {
231 return pyexpat_xmlparser_GetInputContext_impl(self);
232 }
233
234 PyDoc_STRVAR(pyexpat_xmlparser_ExternalEntityParserCreate__doc__,
235 "ExternalEntityParserCreate($self, context, encoding=<unrepresentable>,\n"
236 " /)\n"
237 "--\n"
238 "\n"
239 "Create a parser for parsing an external entity based on the information passed to the ExternalEntityRefHandler.");
240
241 #define PYEXPAT_XMLPARSER_EXTERNALENTITYPARSERCREATE_METHODDEF \
242 {"ExternalEntityParserCreate", _PyCFunction_CAST(pyexpat_xmlparser_ExternalEntityParserCreate), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_ExternalEntityParserCreate__doc__},
243
244 static PyObject *
245 pyexpat_xmlparser_ExternalEntityParserCreate_impl(xmlparseobject *self,
246 PyTypeObject *cls,
247 const char *context,
248 const char *encoding);
249
250 static PyObject *
251 pyexpat_xmlparser_ExternalEntityParserCreate(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
252 {
253 PyObject *return_value = NULL;
254 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
255 # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
256 #else
257 # define KWTUPLE NULL
258 #endif
259
260 static const char * const _keywords[] = {"", "", NULL};
261 static _PyArg_Parser _parser = {
262 .keywords = _keywords,
263 .fname = "ExternalEntityParserCreate",
264 .kwtuple = KWTUPLE,
265 };
266 #undef KWTUPLE
267 PyObject *argsbuf[2];
268 const char *context;
269 const char *encoding = NULL;
270
271 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
272 if (!args) {
273 goto exit;
274 }
275 if (args[0] == Py_None) {
276 context = NULL;
277 }
278 else if (PyUnicode_Check(args[0])) {
279 Py_ssize_t context_length;
280 context = PyUnicode_AsUTF8AndSize(args[0], &context_length);
281 if (context == NULL) {
282 goto exit;
283 }
284 if (strlen(context) != (size_t)context_length) {
285 PyErr_SetString(PyExc_ValueError, "embedded null character");
286 goto exit;
287 }
288 }
289 else {
290 _PyArg_BadArgument("ExternalEntityParserCreate", "argument 1", "str or None", args[0]);
291 goto exit;
292 }
293 if (nargs < 2) {
294 goto skip_optional_posonly;
295 }
296 if (!PyUnicode_Check(args[1])) {
297 _PyArg_BadArgument("ExternalEntityParserCreate", "argument 2", "str", args[1]);
298 goto exit;
299 }
300 Py_ssize_t encoding_length;
301 encoding = PyUnicode_AsUTF8AndSize(args[1], &encoding_length);
302 if (encoding == NULL) {
303 goto exit;
304 }
305 if (strlen(encoding) != (size_t)encoding_length) {
306 PyErr_SetString(PyExc_ValueError, "embedded null character");
307 goto exit;
308 }
309 skip_optional_posonly:
310 return_value = pyexpat_xmlparser_ExternalEntityParserCreate_impl(self, cls, context, encoding);
311
312 exit:
313 return return_value;
314 }
315
316 PyDoc_STRVAR(pyexpat_xmlparser_SetParamEntityParsing__doc__,
317 "SetParamEntityParsing($self, flag, /)\n"
318 "--\n"
319 "\n"
320 "Controls parsing of parameter entities (including the external DTD subset).\n"
321 "\n"
322 "Possible flag values are XML_PARAM_ENTITY_PARSING_NEVER,\n"
323 "XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE and\n"
324 "XML_PARAM_ENTITY_PARSING_ALWAYS. Returns true if setting the flag\n"
325 "was successful.");
326
327 #define PYEXPAT_XMLPARSER_SETPARAMENTITYPARSING_METHODDEF \
328 {"SetParamEntityParsing", (PyCFunction)pyexpat_xmlparser_SetParamEntityParsing, METH_O, pyexpat_xmlparser_SetParamEntityParsing__doc__},
329
330 static PyObject *
331 pyexpat_xmlparser_SetParamEntityParsing_impl(xmlparseobject *self, int flag);
332
333 static PyObject *
334 pyexpat_xmlparser_SetParamEntityParsing(xmlparseobject *self, PyObject *arg)
335 {
336 PyObject *return_value = NULL;
337 int flag;
338
339 flag = PyLong_AsInt(arg);
340 if (flag == -1 && PyErr_Occurred()) {
341 goto exit;
342 }
343 return_value = pyexpat_xmlparser_SetParamEntityParsing_impl(self, flag);
344
345 exit:
346 return return_value;
347 }
348
349 #if (XML_COMBINED_VERSION >= 19505)
350
351 PyDoc_STRVAR(pyexpat_xmlparser_UseForeignDTD__doc__,
352 "UseForeignDTD($self, flag=True, /)\n"
353 "--\n"
354 "\n"
355 "Allows the application to provide an artificial external subset if one is not specified as part of the document instance.\n"
356 "\n"
357 "This readily allows the use of a \'default\' document type controlled by the\n"
358 "application, while still getting the advantage of providing document type\n"
359 "information to the parser. \'flag\' defaults to True if not provided.");
360
361 #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF \
362 {"UseForeignDTD", _PyCFunction_CAST(pyexpat_xmlparser_UseForeignDTD), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_UseForeignDTD__doc__},
363
364 static PyObject *
365 pyexpat_xmlparser_UseForeignDTD_impl(xmlparseobject *self, PyTypeObject *cls,
366 int flag);
367
368 static PyObject *
369 pyexpat_xmlparser_UseForeignDTD(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
370 {
371 PyObject *return_value = NULL;
372 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
373 # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
374 #else
375 # define KWTUPLE NULL
376 #endif
377
378 static const char * const _keywords[] = {"", NULL};
379 static _PyArg_Parser _parser = {
380 .keywords = _keywords,
381 .fname = "UseForeignDTD",
382 .kwtuple = KWTUPLE,
383 };
384 #undef KWTUPLE
385 PyObject *argsbuf[1];
386 int flag = 1;
387
388 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
389 if (!args) {
390 goto exit;
391 }
392 if (nargs < 1) {
393 goto skip_optional_posonly;
394 }
395 flag = PyObject_IsTrue(args[0]);
396 if (flag < 0) {
397 goto exit;
398 }
399 skip_optional_posonly:
400 return_value = pyexpat_xmlparser_UseForeignDTD_impl(self, cls, flag);
401
402 exit:
403 return return_value;
404 }
405
406 #endif /* (XML_COMBINED_VERSION >= 19505) */
407
408 #if (XML_COMBINED_VERSION >= 20702)
409
410 PyDoc_STRVAR(pyexpat_xmlparser_SetAllocTrackerActivationThreshold__doc__,
411 "SetAllocTrackerActivationThreshold($self, threshold, /)\n"
412 "--\n"
413 "\n"
414 "Sets the number of allocated bytes of dynamic memory needed to activate protection against disproportionate use of RAM.\n"
415 "\n"
416 "By default, parser objects have an allocation activation threshold of 64 MiB.");
417
418 #define PYEXPAT_XMLPARSER_SETALLOCTRACKERACTIVATIONTHRESHOLD_METHODDEF \
419 {"SetAllocTrackerActivationThreshold", _PyCFunction_CAST(pyexpat_xmlparser_SetAllocTrackerActivationThreshold), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_SetAllocTrackerActivationThreshold__doc__},
420
421 static PyObject *
422 pyexpat_xmlparser_SetAllocTrackerActivationThreshold_impl(xmlparseobject *self,
423 PyTypeObject *cls,
424 unsigned long long threshold);
425
426 static PyObject *
427 pyexpat_xmlparser_SetAllocTrackerActivationThreshold(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
428 {
429 PyObject *return_value = NULL;
430 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
431 # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
432 #else
433 # define KWTUPLE NULL
434 #endif
435
436 static const char * const _keywords[] = {"", NULL};
437 static _PyArg_Parser _parser = {
438 .keywords = _keywords,
439 .fname = "SetAllocTrackerActivationThreshold",
440 .kwtuple = KWTUPLE,
441 };
442 #undef KWTUPLE
443 PyObject *argsbuf[1];
444 unsigned long long threshold;
445
446 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
447 if (!args) {
448 goto exit;
449 }
450 if (!_PyLong_UnsignedLongLong_Converter(args[0], &threshold)) {
451 goto exit;
452 }
453 return_value = pyexpat_xmlparser_SetAllocTrackerActivationThreshold_impl(self, cls, threshold);
454
455 exit:
456 return return_value;
457 }
458
459 #endif /* (XML_COMBINED_VERSION >= 20702) */
460
461 #if (XML_COMBINED_VERSION >= 20702)
462
463 PyDoc_STRVAR(pyexpat_xmlparser_SetAllocTrackerMaximumAmplification__doc__,
464 "SetAllocTrackerMaximumAmplification($self, max_factor, /)\n"
465 "--\n"
466 "\n"
467 "Sets the maximum amplification factor between direct input and bytes of dynamic memory allocated.\n"
468 "\n"
469 "The amplification factor is calculated as \"allocated / direct\" while parsing,\n"
470 "where \"direct\" is the number of bytes read from the primary document in parsing\n"
471 "and \"allocated\" is the number of bytes of dynamic memory allocated in the parser\n"
472 "hierarchy.\n"
473 "\n"
474 "The \'max_factor\' value must be a non-NaN floating point value greater than\n"
475 "or equal to 1.0. Amplification factors greater than 100.0 can be observed\n"
476 "near the start of parsing even with benign files in practice. In particular,\n"
477 "the activation threshold should be carefully chosen to avoid false positives.\n"
478 "\n"
479 "By default, parser objects have a maximum amplification factor of 100.0.");
480
481 #define PYEXPAT_XMLPARSER_SETALLOCTRACKERMAXIMUMAMPLIFICATION_METHODDEF \
482 {"SetAllocTrackerMaximumAmplification", _PyCFunction_CAST(pyexpat_xmlparser_SetAllocTrackerMaximumAmplification), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_SetAllocTrackerMaximumAmplification__doc__},
483
484 static PyObject *
485 pyexpat_xmlparser_SetAllocTrackerMaximumAmplification_impl(xmlparseobject *self,
486 PyTypeObject *cls,
487 float max_factor);
488
489 static PyObject *
490 pyexpat_xmlparser_SetAllocTrackerMaximumAmplification(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
491 {
492 PyObject *return_value = NULL;
493 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
494 # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
495 #else
496 # define KWTUPLE NULL
497 #endif
498
499 static const char * const _keywords[] = {"", NULL};
500 static _PyArg_Parser _parser = {
501 .keywords = _keywords,
502 .fname = "SetAllocTrackerMaximumAmplification",
503 .kwtuple = KWTUPLE,
504 };
505 #undef KWTUPLE
506 PyObject *argsbuf[1];
507 float max_factor;
508
509 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
510 if (!args) {
511 goto exit;
512 }
513 if (PyFloat_CheckExact(args[0])) {
514 max_factor = (float) (PyFloat_AS_DOUBLE(args[0]));
515 }
516 else
517 {
518 max_factor = (float) PyFloat_AsDouble(args[0]);
519 if (max_factor == -1.0 && PyErr_Occurred()) {
520 goto exit;
521 }
522 }
523 return_value = pyexpat_xmlparser_SetAllocTrackerMaximumAmplification_impl(self, cls, max_factor);
524
525 exit:
526 return return_value;
527 }
528
529 #endif /* (XML_COMBINED_VERSION >= 20702) */
530
531 PyDoc_STRVAR(pyexpat_ParserCreate__doc__,
532 "ParserCreate($module, /, encoding=None, namespace_separator=None,\n"
533 " intern=<unrepresentable>)\n"
534 "--\n"
535 "\n"
536 "Return a new XML parser object.");
537
538 #define PYEXPAT_PARSERCREATE_METHODDEF \
539 {"ParserCreate", _PyCFunction_CAST(pyexpat_ParserCreate), METH_FASTCALL|METH_KEYWORDS, pyexpat_ParserCreate__doc__},
540
541 static PyObject *
542 pyexpat_ParserCreate_impl(PyObject *module, const char *encoding,
543 const char *namespace_separator, PyObject *intern);
544
545 static PyObject *
546 pyexpat_ParserCreate(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
547 {
548 PyObject *return_value = NULL;
549 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
550
551 #define NUM_KEYWORDS 3
552 static struct {
553 PyGC_Head _this_is_not_used;
554 PyObject_VAR_HEAD
555 PyObject *ob_item[NUM_KEYWORDS];
556 } _kwtuple = {
557 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
558 .ob_item = { &_Py_ID(encoding), &_Py_ID(namespace_separator), &_Py_ID(intern), },
559 };
560 #undef NUM_KEYWORDS
561 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
562
563 #else // !Py_BUILD_CORE
564 # define KWTUPLE NULL
565 #endif // !Py_BUILD_CORE
566
567 static const char * const _keywords[] = {"encoding", "namespace_separator", "intern", NULL};
568 static _PyArg_Parser _parser = {
569 .keywords = _keywords,
570 .fname = "ParserCreate",
571 .kwtuple = KWTUPLE,
572 };
573 #undef KWTUPLE
574 PyObject *argsbuf[3];
575 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
576 const char *encoding = NULL;
577 const char *namespace_separator = NULL;
578 PyObject *intern = NULL;
579
580 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 3, 0, argsbuf);
581 if (!args) {
582 goto exit;
583 }
584 if (!noptargs) {
585 goto skip_optional_pos;
586 }
587 if (args[0]) {
588 if (args[0] == Py_None) {
589 encoding = NULL;
590 }
591 else if (PyUnicode_Check(args[0])) {
592 Py_ssize_t encoding_length;
593 encoding = PyUnicode_AsUTF8AndSize(args[0], &encoding_length);
594 if (encoding == NULL) {
595 goto exit;
596 }
597 if (strlen(encoding) != (size_t)encoding_length) {
598 PyErr_SetString(PyExc_ValueError, "embedded null character");
599 goto exit;
600 }
601 }
602 else {
603 _PyArg_BadArgument("ParserCreate", "argument 'encoding'", "str or None", args[0]);
604 goto exit;
605 }
606 if (!--noptargs) {
607 goto skip_optional_pos;
608 }
609 }
610 if (args[1]) {
611 if (args[1] == Py_None) {
612 namespace_separator = NULL;
613 }
614 else if (PyUnicode_Check(args[1])) {
615 Py_ssize_t namespace_separator_length;
616 namespace_separator = PyUnicode_AsUTF8AndSize(args[1], &namespace_separator_length);
617 if (namespace_separator == NULL) {
618 goto exit;
619 }
620 if (strlen(namespace_separator) != (size_t)namespace_separator_length) {
621 PyErr_SetString(PyExc_ValueError, "embedded null character");
622 goto exit;
623 }
624 }
625 else {
626 _PyArg_BadArgument("ParserCreate", "argument 'namespace_separator'", "str or None", args[1]);
627 goto exit;
628 }
629 if (!--noptargs) {
630 goto skip_optional_pos;
631 }
632 }
633 intern = args[2];
634 skip_optional_pos:
635 return_value = pyexpat_ParserCreate_impl(module, encoding, namespace_separator, intern);
636
637 exit:
638 return return_value;
639 }
640
641 PyDoc_STRVAR(pyexpat_ErrorString__doc__,
642 "ErrorString($module, code, /)\n"
643 "--\n"
644 "\n"
645 "Returns string error for given number.");
646
647 #define PYEXPAT_ERRORSTRING_METHODDEF \
648 {"ErrorString", (PyCFunction)pyexpat_ErrorString, METH_O, pyexpat_ErrorString__doc__},
649
650 static PyObject *
651 pyexpat_ErrorString_impl(PyObject *module, long code);
652
653 static PyObject *
654 pyexpat_ErrorString(PyObject *module, PyObject *arg)
655 {
656 PyObject *return_value = NULL;
657 long code;
658
659 code = PyLong_AsLong(arg);
660 if (code == -1 && PyErr_Occurred()) {
661 goto exit;
662 }
663 return_value = pyexpat_ErrorString_impl(module, code);
664
665 exit:
666 return return_value;
667 }
668
669 #ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
670 #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
671 #endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */
672
673 #ifndef PYEXPAT_XMLPARSER_SETALLOCTRACKERACTIVATIONTHRESHOLD_METHODDEF
674 #define PYEXPAT_XMLPARSER_SETALLOCTRACKERACTIVATIONTHRESHOLD_METHODDEF
675 #endif /* !defined(PYEXPAT_XMLPARSER_SETALLOCTRACKERACTIVATIONTHRESHOLD_METHODDEF) */
676
677 #ifndef PYEXPAT_XMLPARSER_SETALLOCTRACKERMAXIMUMAMPLIFICATION_METHODDEF
678 #define PYEXPAT_XMLPARSER_SETALLOCTRACKERMAXIMUMAMPLIFICATION_METHODDEF
679 #endif /* !defined(PYEXPAT_XMLPARSER_SETALLOCTRACKERMAXIMUMAMPLIFICATION_METHODDEF) */
680 /*[clinic end generated code: output=2e787fd99710eb5b input=a9049054013a1b77]*/