_elementtree.c.h 37 KB

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