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