Debian Codegraph @

Objects/clinic/typevarobject.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_ID()
8 #endif
9 #include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
10
11 PyDoc_STRVAR(typevar_new__doc__,
12 "typevar(name, *constraints, bound=None, default=typing.NoDefault,\n"
13 " covariant=False, contravariant=False, infer_variance=False)\n"
14 "--\n"
15 "\n"
16 "Create a TypeVar.");
17
18 static PyObject *
19 typevar_new_impl(PyTypeObject *type, PyObject *name, PyObject *constraints,
20 PyObject *bound, PyObject *default_value, int covariant,
21 int contravariant, int infer_variance);
22
23 static PyObject *
24 typevar_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
25 {
26 PyObject *return_value = NULL;
27 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
28
29 #define NUM_KEYWORDS 6
30 static struct {
31 PyGC_Head _this_is_not_used;
32 PyObject_VAR_HEAD
33 Py_hash_t ob_hash;
34 PyObject *ob_item[NUM_KEYWORDS];
35 } _kwtuple = {
36 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
37 .ob_hash = -1,
38 .ob_item = { &_Py_ID(name), &_Py_ID(bound), &_Py_ID(default), &_Py_ID(covariant), &_Py_ID(contravariant), &_Py_ID(infer_variance), },
39 };
40 #undef NUM_KEYWORDS
41 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
42
43 #else // !Py_BUILD_CORE
44 # define KWTUPLE NULL
45 #endif // !Py_BUILD_CORE
46
47 static const char * const _keywords[] = {"name", "bound", "default", "covariant", "contravariant", "infer_variance", NULL};
48 static _PyArg_Parser _parser = {
49 .keywords = _keywords,
50 .fname = "typevar",
51 .kwtuple = KWTUPLE,
52 };
53 #undef KWTUPLE
54 PyObject *argsbuf[6];
55 PyObject * const *fastargs;
56 Py_ssize_t nargs = PyTuple_GET_SIZE(args);
57 Py_ssize_t noptargs = Py_MIN(nargs, 1) + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;
58 PyObject *name;
59 PyObject *constraints = NULL;
60 PyObject *bound = Py_None;
61 PyObject *default_value = &_Py_NoDefaultStruct;
62 int covariant = 0;
63 int contravariant = 0;
64 int infer_variance = 0;
65
66 fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser,
67 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 1, argsbuf);
68 if (!fastargs) {
69 goto exit;
70 }
71 if (!PyUnicode_Check(fastargs[0])) {
72 _PyArg_BadArgument("typevar", "argument 'name'", "str", fastargs[0]);
73 goto exit;
74 }
75 name = fastargs[0];
76 if (!noptargs) {
77 goto skip_optional_kwonly;
78 }
79 if (fastargs[1]) {
80 bound = fastargs[1];
81 if (!--noptargs) {
82 goto skip_optional_kwonly;
83 }
84 }
85 if (fastargs[2]) {
86 default_value = fastargs[2];
87 if (!--noptargs) {
88 goto skip_optional_kwonly;
89 }
90 }
91 if (fastargs[3]) {
92 covariant = PyObject_IsTrue(fastargs[3]);
93 if (covariant < 0) {
94 goto exit;
95 }
96 if (!--noptargs) {
97 goto skip_optional_kwonly;
98 }
99 }
100 if (fastargs[4]) {
101 contravariant = PyObject_IsTrue(fastargs[4]);
102 if (contravariant < 0) {
103 goto exit;
104 }
105 if (!--noptargs) {
106 goto skip_optional_kwonly;
107 }
108 }
109 infer_variance = PyObject_IsTrue(fastargs[5]);
110 if (infer_variance < 0) {
111 goto exit;
112 }
113 skip_optional_kwonly:
114 constraints = PyTuple_GetSlice(args, 1, PY_SSIZE_T_MAX);
115 if (!constraints) {
116 goto exit;
117 }
118 return_value = typevar_new_impl(type, name, constraints, bound, default_value, covariant, contravariant, infer_variance);
119
120 exit:
121 /* Cleanup for constraints */
122 Py_XDECREF(constraints);
123
124 return return_value;
125 }
126
127 PyDoc_STRVAR(typevar_typing_subst__doc__,
128 "__typing_subst__($self, arg, /)\n"
129 "--\n"
130 "\n");
131
132 #define TYPEVAR_TYPING_SUBST_METHODDEF \
133 {"__typing_subst__", (PyCFunction)typevar_typing_subst, METH_O, typevar_typing_subst__doc__},
134
135 static PyObject *
136 typevar_typing_subst_impl(typevarobject *self, PyObject *arg);
137
138 static PyObject *
139 typevar_typing_subst(PyObject *self, PyObject *arg)
140 {
141 PyObject *return_value = NULL;
142
143 return_value = typevar_typing_subst_impl((typevarobject *)self, arg);
144
145 return return_value;
146 }
147
148 PyDoc_STRVAR(typevar_typing_prepare_subst__doc__,
149 "__typing_prepare_subst__($self, alias, args, /)\n"
150 "--\n"
151 "\n");
152
153 #define TYPEVAR_TYPING_PREPARE_SUBST_METHODDEF \
154 {"__typing_prepare_subst__", _PyCFunction_CAST(typevar_typing_prepare_subst), METH_FASTCALL, typevar_typing_prepare_subst__doc__},
155
156 static PyObject *
157 typevar_typing_prepare_subst_impl(typevarobject *self, PyObject *alias,
158 PyObject *args);
159
160 static PyObject *
161 typevar_typing_prepare_subst(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
162 {
163 PyObject *return_value = NULL;
164 PyObject *alias;
165 PyObject *__clinic_args;
166
167 if (!_PyArg_CheckPositional("__typing_prepare_subst__", nargs, 2, 2)) {
168 goto exit;
169 }
170 alias = args[0];
171 __clinic_args = args[1];
172 return_value = typevar_typing_prepare_subst_impl((typevarobject *)self, alias, __clinic_args);
173
174 exit:
175 return return_value;
176 }
177
178 PyDoc_STRVAR(typevar_reduce__doc__,
179 "__reduce__($self, /)\n"
180 "--\n"
181 "\n");
182
183 #define TYPEVAR_REDUCE_METHODDEF \
184 {"__reduce__", (PyCFunction)typevar_reduce, METH_NOARGS, typevar_reduce__doc__},
185
186 static PyObject *
187 typevar_reduce_impl(typevarobject *self);
188
189 static PyObject *
190 typevar_reduce(PyObject *self, PyObject *Py_UNUSED(ignored))
191 {
192 return typevar_reduce_impl((typevarobject *)self);
193 }
194
195 PyDoc_STRVAR(typevar_has_default__doc__,
196 "has_default($self, /)\n"
197 "--\n"
198 "\n");
199
200 #define TYPEVAR_HAS_DEFAULT_METHODDEF \
201 {"has_default", (PyCFunction)typevar_has_default, METH_NOARGS, typevar_has_default__doc__},
202
203 static PyObject *
204 typevar_has_default_impl(typevarobject *self);
205
206 static PyObject *
207 typevar_has_default(PyObject *self, PyObject *Py_UNUSED(ignored))
208 {
209 return typevar_has_default_impl((typevarobject *)self);
210 }
211
212 PyDoc_STRVAR(paramspecargs_new__doc__,
213 "paramspecargs(origin)\n"
214 "--\n"
215 "\n"
216 "Create a ParamSpecArgs object.");
217
218 static PyObject *
219 paramspecargs_new_impl(PyTypeObject *type, PyObject *origin);
220
221 static PyObject *
222 paramspecargs_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
223 {
224 PyObject *return_value = NULL;
225 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
226
227 #define NUM_KEYWORDS 1
228 static struct {
229 PyGC_Head _this_is_not_used;
230 PyObject_VAR_HEAD
231 Py_hash_t ob_hash;
232 PyObject *ob_item[NUM_KEYWORDS];
233 } _kwtuple = {
234 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
235 .ob_hash = -1,
236 .ob_item = { &_Py_ID(origin), },
237 };
238 #undef NUM_KEYWORDS
239 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
240
241 #else // !Py_BUILD_CORE
242 # define KWTUPLE NULL
243 #endif // !Py_BUILD_CORE
244
245 static const char * const _keywords[] = {"origin", NULL};
246 static _PyArg_Parser _parser = {
247 .keywords = _keywords,
248 .fname = "paramspecargs",
249 .kwtuple = KWTUPLE,
250 };
251 #undef KWTUPLE
252 PyObject *argsbuf[1];
253 PyObject * const *fastargs;
254 Py_ssize_t nargs = PyTuple_GET_SIZE(args);
255 PyObject *origin;
256
257 fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser,
258 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
259 if (!fastargs) {
260 goto exit;
261 }
262 origin = fastargs[0];
263 return_value = paramspecargs_new_impl(type, origin);
264
265 exit:
266 return return_value;
267 }
268
269 PyDoc_STRVAR(paramspeckwargs_new__doc__,
270 "paramspeckwargs(origin)\n"
271 "--\n"
272 "\n"
273 "Create a ParamSpecKwargs object.");
274
275 static PyObject *
276 paramspeckwargs_new_impl(PyTypeObject *type, PyObject *origin);
277
278 static PyObject *
279 paramspeckwargs_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
280 {
281 PyObject *return_value = NULL;
282 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
283
284 #define NUM_KEYWORDS 1
285 static struct {
286 PyGC_Head _this_is_not_used;
287 PyObject_VAR_HEAD
288 Py_hash_t ob_hash;
289 PyObject *ob_item[NUM_KEYWORDS];
290 } _kwtuple = {
291 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
292 .ob_hash = -1,
293 .ob_item = { &_Py_ID(origin), },
294 };
295 #undef NUM_KEYWORDS
296 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
297
298 #else // !Py_BUILD_CORE
299 # define KWTUPLE NULL
300 #endif // !Py_BUILD_CORE
301
302 static const char * const _keywords[] = {"origin", NULL};
303 static _PyArg_Parser _parser = {
304 .keywords = _keywords,
305 .fname = "paramspeckwargs",
306 .kwtuple = KWTUPLE,
307 };
308 #undef KWTUPLE
309 PyObject *argsbuf[1];
310 PyObject * const *fastargs;
311 Py_ssize_t nargs = PyTuple_GET_SIZE(args);
312 PyObject *origin;
313
314 fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser,
315 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
316 if (!fastargs) {
317 goto exit;
318 }
319 origin = fastargs[0];
320 return_value = paramspeckwargs_new_impl(type, origin);
321
322 exit:
323 return return_value;
324 }
325
326 PyDoc_STRVAR(paramspec_new__doc__,
327 "paramspec(name, *, bound=None, default=typing.NoDefault,\n"
328 " covariant=False, contravariant=False, infer_variance=False)\n"
329 "--\n"
330 "\n"
331 "Create a ParamSpec object.");
332
333 static PyObject *
334 paramspec_new_impl(PyTypeObject *type, PyObject *name, PyObject *bound,
335 PyObject *default_value, int covariant, int contravariant,
336 int infer_variance);
337
338 static PyObject *
339 paramspec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
340 {
341 PyObject *return_value = NULL;
342 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
343
344 #define NUM_KEYWORDS 6
345 static struct {
346 PyGC_Head _this_is_not_used;
347 PyObject_VAR_HEAD
348 Py_hash_t ob_hash;
349 PyObject *ob_item[NUM_KEYWORDS];
350 } _kwtuple = {
351 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
352 .ob_hash = -1,
353 .ob_item = { &_Py_ID(name), &_Py_ID(bound), &_Py_ID(default), &_Py_ID(covariant), &_Py_ID(contravariant), &_Py_ID(infer_variance), },
354 };
355 #undef NUM_KEYWORDS
356 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
357
358 #else // !Py_BUILD_CORE
359 # define KWTUPLE NULL
360 #endif // !Py_BUILD_CORE
361
362 static const char * const _keywords[] = {"name", "bound", "default", "covariant", "contravariant", "infer_variance", NULL};
363 static _PyArg_Parser _parser = {
364 .keywords = _keywords,
365 .fname = "paramspec",
366 .kwtuple = KWTUPLE,
367 };
368 #undef KWTUPLE
369 PyObject *argsbuf[6];
370 PyObject * const *fastargs;
371 Py_ssize_t nargs = PyTuple_GET_SIZE(args);
372 Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;
373 PyObject *name;
374 PyObject *bound = Py_None;
375 PyObject *default_value = &_Py_NoDefaultStruct;
376 int covariant = 0;
377 int contravariant = 0;
378 int infer_variance = 0;
379
380 fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser,
381 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
382 if (!fastargs) {
383 goto exit;
384 }
385 if (!PyUnicode_Check(fastargs[0])) {
386 _PyArg_BadArgument("paramspec", "argument 'name'", "str", fastargs[0]);
387 goto exit;
388 }
389 name = fastargs[0];
390 if (!noptargs) {
391 goto skip_optional_kwonly;
392 }
393 if (fastargs[1]) {
394 bound = fastargs[1];
395 if (!--noptargs) {
396 goto skip_optional_kwonly;
397 }
398 }
399 if (fastargs[2]) {
400 default_value = fastargs[2];
401 if (!--noptargs) {
402 goto skip_optional_kwonly;
403 }
404 }
405 if (fastargs[3]) {
406 covariant = PyObject_IsTrue(fastargs[3]);
407 if (covariant < 0) {
408 goto exit;
409 }
410 if (!--noptargs) {
411 goto skip_optional_kwonly;
412 }
413 }
414 if (fastargs[4]) {
415 contravariant = PyObject_IsTrue(fastargs[4]);
416 if (contravariant < 0) {
417 goto exit;
418 }
419 if (!--noptargs) {
420 goto skip_optional_kwonly;
421 }
422 }
423 infer_variance = PyObject_IsTrue(fastargs[5]);
424 if (infer_variance < 0) {
425 goto exit;
426 }
427 skip_optional_kwonly:
428 return_value = paramspec_new_impl(type, name, bound, default_value, covariant, contravariant, infer_variance);
429
430 exit:
431 return return_value;
432 }
433
434 PyDoc_STRVAR(paramspec_typing_subst__doc__,
435 "__typing_subst__($self, arg, /)\n"
436 "--\n"
437 "\n");
438
439 #define PARAMSPEC_TYPING_SUBST_METHODDEF \
440 {"__typing_subst__", (PyCFunction)paramspec_typing_subst, METH_O, paramspec_typing_subst__doc__},
441
442 static PyObject *
443 paramspec_typing_subst_impl(paramspecobject *self, PyObject *arg);
444
445 static PyObject *
446 paramspec_typing_subst(PyObject *self, PyObject *arg)
447 {
448 PyObject *return_value = NULL;
449
450 return_value = paramspec_typing_subst_impl((paramspecobject *)self, arg);
451
452 return return_value;
453 }
454
455 PyDoc_STRVAR(paramspec_typing_prepare_subst__doc__,
456 "__typing_prepare_subst__($self, alias, args, /)\n"
457 "--\n"
458 "\n");
459
460 #define PARAMSPEC_TYPING_PREPARE_SUBST_METHODDEF \
461 {"__typing_prepare_subst__", _PyCFunction_CAST(paramspec_typing_prepare_subst), METH_FASTCALL, paramspec_typing_prepare_subst__doc__},
462
463 static PyObject *
464 paramspec_typing_prepare_subst_impl(paramspecobject *self, PyObject *alias,
465 PyObject *args);
466
467 static PyObject *
468 paramspec_typing_prepare_subst(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
469 {
470 PyObject *return_value = NULL;
471 PyObject *alias;
472 PyObject *__clinic_args;
473
474 if (!_PyArg_CheckPositional("__typing_prepare_subst__", nargs, 2, 2)) {
475 goto exit;
476 }
477 alias = args[0];
478 __clinic_args = args[1];
479 return_value = paramspec_typing_prepare_subst_impl((paramspecobject *)self, alias, __clinic_args);
480
481 exit:
482 return return_value;
483 }
484
485 PyDoc_STRVAR(paramspec_reduce__doc__,
486 "__reduce__($self, /)\n"
487 "--\n"
488 "\n");
489
490 #define PARAMSPEC_REDUCE_METHODDEF \
491 {"__reduce__", (PyCFunction)paramspec_reduce, METH_NOARGS, paramspec_reduce__doc__},
492
493 static PyObject *
494 paramspec_reduce_impl(paramspecobject *self);
495
496 static PyObject *
497 paramspec_reduce(PyObject *self, PyObject *Py_UNUSED(ignored))
498 {
499 return paramspec_reduce_impl((paramspecobject *)self);
500 }
501
502 PyDoc_STRVAR(paramspec_has_default__doc__,
503 "has_default($self, /)\n"
504 "--\n"
505 "\n");
506
507 #define PARAMSPEC_HAS_DEFAULT_METHODDEF \
508 {"has_default", (PyCFunction)paramspec_has_default, METH_NOARGS, paramspec_has_default__doc__},
509
510 static PyObject *
511 paramspec_has_default_impl(paramspecobject *self);
512
513 static PyObject *
514 paramspec_has_default(PyObject *self, PyObject *Py_UNUSED(ignored))
515 {
516 return paramspec_has_default_impl((paramspecobject *)self);
517 }
518
519 PyDoc_STRVAR(typevartuple__doc__,
520 "typevartuple(name, *, default=typing.NoDefault)\n"
521 "--\n"
522 "\n"
523 "Create a new TypeVarTuple with the given name.");
524
525 static PyObject *
526 typevartuple_impl(PyTypeObject *type, PyObject *name,
527 PyObject *default_value);
528
529 static PyObject *
530 typevartuple(PyTypeObject *type, PyObject *args, PyObject *kwargs)
531 {
532 PyObject *return_value = NULL;
533 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
534
535 #define NUM_KEYWORDS 2
536 static struct {
537 PyGC_Head _this_is_not_used;
538 PyObject_VAR_HEAD
539 Py_hash_t ob_hash;
540 PyObject *ob_item[NUM_KEYWORDS];
541 } _kwtuple = {
542 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
543 .ob_hash = -1,
544 .ob_item = { &_Py_ID(name), &_Py_ID(default), },
545 };
546 #undef NUM_KEYWORDS
547 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
548
549 #else // !Py_BUILD_CORE
550 # define KWTUPLE NULL
551 #endif // !Py_BUILD_CORE
552
553 static const char * const _keywords[] = {"name", "default", NULL};
554 static _PyArg_Parser _parser = {
555 .keywords = _keywords,
556 .fname = "typevartuple",
557 .kwtuple = KWTUPLE,
558 };
559 #undef KWTUPLE
560 PyObject *argsbuf[2];
561 PyObject * const *fastargs;
562 Py_ssize_t nargs = PyTuple_GET_SIZE(args);
563 Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;
564 PyObject *name;
565 PyObject *default_value = &_Py_NoDefaultStruct;
566
567 fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser,
568 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
569 if (!fastargs) {
570 goto exit;
571 }
572 if (!PyUnicode_Check(fastargs[0])) {
573 _PyArg_BadArgument("typevartuple", "argument 'name'", "str", fastargs[0]);
574 goto exit;
575 }
576 name = fastargs[0];
577 if (!noptargs) {
578 goto skip_optional_kwonly;
579 }
580 default_value = fastargs[1];
581 skip_optional_kwonly:
582 return_value = typevartuple_impl(type, name, default_value);
583
584 exit:
585 return return_value;
586 }
587
588 PyDoc_STRVAR(typevartuple_typing_subst__doc__,
589 "__typing_subst__($self, arg, /)\n"
590 "--\n"
591 "\n");
592
593 #define TYPEVARTUPLE_TYPING_SUBST_METHODDEF \
594 {"__typing_subst__", (PyCFunction)typevartuple_typing_subst, METH_O, typevartuple_typing_subst__doc__},
595
596 static PyObject *
597 typevartuple_typing_subst_impl(typevartupleobject *self, PyObject *arg);
598
599 static PyObject *
600 typevartuple_typing_subst(PyObject *self, PyObject *arg)
601 {
602 PyObject *return_value = NULL;
603
604 return_value = typevartuple_typing_subst_impl((typevartupleobject *)self, arg);
605
606 return return_value;
607 }
608
609 PyDoc_STRVAR(typevartuple_typing_prepare_subst__doc__,
610 "__typing_prepare_subst__($self, alias, args, /)\n"
611 "--\n"
612 "\n");
613
614 #define TYPEVARTUPLE_TYPING_PREPARE_SUBST_METHODDEF \
615 {"__typing_prepare_subst__", _PyCFunction_CAST(typevartuple_typing_prepare_subst), METH_FASTCALL, typevartuple_typing_prepare_subst__doc__},
616
617 static PyObject *
618 typevartuple_typing_prepare_subst_impl(typevartupleobject *self,
619 PyObject *alias, PyObject *args);
620
621 static PyObject *
622 typevartuple_typing_prepare_subst(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
623 {
624 PyObject *return_value = NULL;
625 PyObject *alias;
626 PyObject *__clinic_args;
627
628 if (!_PyArg_CheckPositional("__typing_prepare_subst__", nargs, 2, 2)) {
629 goto exit;
630 }
631 alias = args[0];
632 __clinic_args = args[1];
633 return_value = typevartuple_typing_prepare_subst_impl((typevartupleobject *)self, alias, __clinic_args);
634
635 exit:
636 return return_value;
637 }
638
639 PyDoc_STRVAR(typevartuple_reduce__doc__,
640 "__reduce__($self, /)\n"
641 "--\n"
642 "\n");
643
644 #define TYPEVARTUPLE_REDUCE_METHODDEF \
645 {"__reduce__", (PyCFunction)typevartuple_reduce, METH_NOARGS, typevartuple_reduce__doc__},
646
647 static PyObject *
648 typevartuple_reduce_impl(typevartupleobject *self);
649
650 static PyObject *
651 typevartuple_reduce(PyObject *self, PyObject *Py_UNUSED(ignored))
652 {
653 return typevartuple_reduce_impl((typevartupleobject *)self);
654 }
655
656 PyDoc_STRVAR(typevartuple_has_default__doc__,
657 "has_default($self, /)\n"
658 "--\n"
659 "\n");
660
661 #define TYPEVARTUPLE_HAS_DEFAULT_METHODDEF \
662 {"has_default", (PyCFunction)typevartuple_has_default, METH_NOARGS, typevartuple_has_default__doc__},
663
664 static PyObject *
665 typevartuple_has_default_impl(typevartupleobject *self);
666
667 static PyObject *
668 typevartuple_has_default(PyObject *self, PyObject *Py_UNUSED(ignored))
669 {
670 return typevartuple_has_default_impl((typevartupleobject *)self);
671 }
672
673 PyDoc_STRVAR(typealias_reduce__doc__,
674 "__reduce__($self, /)\n"
675 "--\n"
676 "\n");
677
678 #define TYPEALIAS_REDUCE_METHODDEF \
679 {"__reduce__", (PyCFunction)typealias_reduce, METH_NOARGS, typealias_reduce__doc__},
680
681 static PyObject *
682 typealias_reduce_impl(typealiasobject *self);
683
684 static PyObject *
685 typealias_reduce(PyObject *self, PyObject *Py_UNUSED(ignored))
686 {
687 return typealias_reduce_impl((typealiasobject *)self);
688 }
689
690 PyDoc_STRVAR(typealias_new__doc__,
691 "typealias(name, value, *, type_params=<unrepresentable>)\n"
692 "--\n"
693 "\n"
694 "Create a TypeAliasType.");
695
696 static PyObject *
697 typealias_new_impl(PyTypeObject *type, PyObject *name, PyObject *value,
698 PyObject *type_params);
699
700 static PyObject *
701 typealias_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
702 {
703 PyObject *return_value = NULL;
704 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
705
706 #define NUM_KEYWORDS 3
707 static struct {
708 PyGC_Head _this_is_not_used;
709 PyObject_VAR_HEAD
710 Py_hash_t ob_hash;
711 PyObject *ob_item[NUM_KEYWORDS];
712 } _kwtuple = {
713 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
714 .ob_hash = -1,
715 .ob_item = { &_Py_ID(name), &_Py_ID(value), &_Py_ID(type_params), },
716 };
717 #undef NUM_KEYWORDS
718 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
719
720 #else // !Py_BUILD_CORE
721 # define KWTUPLE NULL
722 #endif // !Py_BUILD_CORE
723
724 static const char * const _keywords[] = {"name", "value", "type_params", NULL};
725 static _PyArg_Parser _parser = {
726 .keywords = _keywords,
727 .fname = "typealias",
728 .kwtuple = KWTUPLE,
729 };
730 #undef KWTUPLE
731 PyObject *argsbuf[3];
732 PyObject * const *fastargs;
733 Py_ssize_t nargs = PyTuple_GET_SIZE(args);
734 Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 2;
735 PyObject *name;
736 PyObject *value;
737 PyObject *type_params = NULL;
738
739 fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser,
740 /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
741 if (!fastargs) {
742 goto exit;
743 }
744 if (!PyUnicode_Check(fastargs[0])) {
745 _PyArg_BadArgument("typealias", "argument 'name'", "str", fastargs[0]);
746 goto exit;
747 }
748 name = fastargs[0];
749 value = fastargs[1];
750 if (!noptargs) {
751 goto skip_optional_kwonly;
752 }
753 type_params = fastargs[2];
754 skip_optional_kwonly:
755 return_value = typealias_new_impl(type, name, value, type_params);
756
757 exit:
758 return return_value;
759 }
760 /*[clinic end generated code: output=9dad71445e079303 input=a9049054013a1b77]*/