(root)/
Python-3.11.7/
Modules/
_sre/
clinic/
sre.c.h
       1  /*[clinic input]
       2  preserve
       3  [clinic start generated code]*/
       4  
       5  PyDoc_STRVAR(_sre_getcodesize__doc__,
       6  "getcodesize($module, /)\n"
       7  "--\n"
       8  "\n");
       9  
      10  #define _SRE_GETCODESIZE_METHODDEF    \
      11      {"getcodesize", (PyCFunction)_sre_getcodesize, METH_NOARGS, _sre_getcodesize__doc__},
      12  
      13  static int
      14  _sre_getcodesize_impl(PyObject *module);
      15  
      16  static PyObject *
      17  _sre_getcodesize(PyObject *module, PyObject *Py_UNUSED(ignored))
      18  {
      19      PyObject *return_value = NULL;
      20      int _return_value;
      21  
      22      _return_value = _sre_getcodesize_impl(module);
      23      if ((_return_value == -1) && PyErr_Occurred()) {
      24          goto exit;
      25      }
      26      return_value = PyLong_FromLong((long)_return_value);
      27  
      28  exit:
      29      return return_value;
      30  }
      31  
      32  PyDoc_STRVAR(_sre_ascii_iscased__doc__,
      33  "ascii_iscased($module, character, /)\n"
      34  "--\n"
      35  "\n");
      36  
      37  #define _SRE_ASCII_ISCASED_METHODDEF    \
      38      {"ascii_iscased", (PyCFunction)_sre_ascii_iscased, METH_O, _sre_ascii_iscased__doc__},
      39  
      40  static int
      41  _sre_ascii_iscased_impl(PyObject *module, int character);
      42  
      43  static PyObject *
      44  _sre_ascii_iscased(PyObject *module, PyObject *arg)
      45  {
      46      PyObject *return_value = NULL;
      47      int character;
      48      int _return_value;
      49  
      50      character = _PyLong_AsInt(arg);
      51      if (character == -1 && PyErr_Occurred()) {
      52          goto exit;
      53      }
      54      _return_value = _sre_ascii_iscased_impl(module, character);
      55      if ((_return_value == -1) && PyErr_Occurred()) {
      56          goto exit;
      57      }
      58      return_value = PyBool_FromLong((long)_return_value);
      59  
      60  exit:
      61      return return_value;
      62  }
      63  
      64  PyDoc_STRVAR(_sre_unicode_iscased__doc__,
      65  "unicode_iscased($module, character, /)\n"
      66  "--\n"
      67  "\n");
      68  
      69  #define _SRE_UNICODE_ISCASED_METHODDEF    \
      70      {"unicode_iscased", (PyCFunction)_sre_unicode_iscased, METH_O, _sre_unicode_iscased__doc__},
      71  
      72  static int
      73  _sre_unicode_iscased_impl(PyObject *module, int character);
      74  
      75  static PyObject *
      76  _sre_unicode_iscased(PyObject *module, PyObject *arg)
      77  {
      78      PyObject *return_value = NULL;
      79      int character;
      80      int _return_value;
      81  
      82      character = _PyLong_AsInt(arg);
      83      if (character == -1 && PyErr_Occurred()) {
      84          goto exit;
      85      }
      86      _return_value = _sre_unicode_iscased_impl(module, character);
      87      if ((_return_value == -1) && PyErr_Occurred()) {
      88          goto exit;
      89      }
      90      return_value = PyBool_FromLong((long)_return_value);
      91  
      92  exit:
      93      return return_value;
      94  }
      95  
      96  PyDoc_STRVAR(_sre_ascii_tolower__doc__,
      97  "ascii_tolower($module, character, /)\n"
      98  "--\n"
      99  "\n");
     100  
     101  #define _SRE_ASCII_TOLOWER_METHODDEF    \
     102      {"ascii_tolower", (PyCFunction)_sre_ascii_tolower, METH_O, _sre_ascii_tolower__doc__},
     103  
     104  static int
     105  _sre_ascii_tolower_impl(PyObject *module, int character);
     106  
     107  static PyObject *
     108  _sre_ascii_tolower(PyObject *module, PyObject *arg)
     109  {
     110      PyObject *return_value = NULL;
     111      int character;
     112      int _return_value;
     113  
     114      character = _PyLong_AsInt(arg);
     115      if (character == -1 && PyErr_Occurred()) {
     116          goto exit;
     117      }
     118      _return_value = _sre_ascii_tolower_impl(module, character);
     119      if ((_return_value == -1) && PyErr_Occurred()) {
     120          goto exit;
     121      }
     122      return_value = PyLong_FromLong((long)_return_value);
     123  
     124  exit:
     125      return return_value;
     126  }
     127  
     128  PyDoc_STRVAR(_sre_unicode_tolower__doc__,
     129  "unicode_tolower($module, character, /)\n"
     130  "--\n"
     131  "\n");
     132  
     133  #define _SRE_UNICODE_TOLOWER_METHODDEF    \
     134      {"unicode_tolower", (PyCFunction)_sre_unicode_tolower, METH_O, _sre_unicode_tolower__doc__},
     135  
     136  static int
     137  _sre_unicode_tolower_impl(PyObject *module, int character);
     138  
     139  static PyObject *
     140  _sre_unicode_tolower(PyObject *module, PyObject *arg)
     141  {
     142      PyObject *return_value = NULL;
     143      int character;
     144      int _return_value;
     145  
     146      character = _PyLong_AsInt(arg);
     147      if (character == -1 && PyErr_Occurred()) {
     148          goto exit;
     149      }
     150      _return_value = _sre_unicode_tolower_impl(module, character);
     151      if ((_return_value == -1) && PyErr_Occurred()) {
     152          goto exit;
     153      }
     154      return_value = PyLong_FromLong((long)_return_value);
     155  
     156  exit:
     157      return return_value;
     158  }
     159  
     160  PyDoc_STRVAR(_sre_SRE_Pattern_match__doc__,
     161  "match($self, /, string, pos=0, endpos=sys.maxsize)\n"
     162  "--\n"
     163  "\n"
     164  "Matches zero or more characters at the beginning of the string.");
     165  
     166  #define _SRE_SRE_PATTERN_MATCH_METHODDEF    \
     167      {"match", _PyCFunction_CAST(_sre_SRE_Pattern_match), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_match__doc__},
     168  
     169  static PyObject *
     170  _sre_SRE_Pattern_match_impl(PatternObject *self, PyTypeObject *cls,
     171                              PyObject *string, Py_ssize_t pos,
     172                              Py_ssize_t endpos);
     173  
     174  static PyObject *
     175  _sre_SRE_Pattern_match(PatternObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     176  {
     177      PyObject *return_value = NULL;
     178      static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
     179      static _PyArg_Parser _parser = {NULL, _keywords, "match", 0};
     180      PyObject *argsbuf[3];
     181      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
     182      PyObject *string;
     183      Py_ssize_t pos = 0;
     184      Py_ssize_t endpos = PY_SSIZE_T_MAX;
     185  
     186      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
     187      if (!args) {
     188          goto exit;
     189      }
     190      string = args[0];
     191      if (!noptargs) {
     192          goto skip_optional_pos;
     193      }
     194      if (args[1]) {
     195          {
     196              Py_ssize_t ival = -1;
     197              PyObject *iobj = _PyNumber_Index(args[1]);
     198              if (iobj != NULL) {
     199                  ival = PyLong_AsSsize_t(iobj);
     200                  Py_DECREF(iobj);
     201              }
     202              if (ival == -1 && PyErr_Occurred()) {
     203                  goto exit;
     204              }
     205              pos = ival;
     206          }
     207          if (!--noptargs) {
     208              goto skip_optional_pos;
     209          }
     210      }
     211      {
     212          Py_ssize_t ival = -1;
     213          PyObject *iobj = _PyNumber_Index(args[2]);
     214          if (iobj != NULL) {
     215              ival = PyLong_AsSsize_t(iobj);
     216              Py_DECREF(iobj);
     217          }
     218          if (ival == -1 && PyErr_Occurred()) {
     219              goto exit;
     220          }
     221          endpos = ival;
     222      }
     223  skip_optional_pos:
     224      return_value = _sre_SRE_Pattern_match_impl(self, cls, string, pos, endpos);
     225  
     226  exit:
     227      return return_value;
     228  }
     229  
     230  PyDoc_STRVAR(_sre_SRE_Pattern_fullmatch__doc__,
     231  "fullmatch($self, /, string, pos=0, endpos=sys.maxsize)\n"
     232  "--\n"
     233  "\n"
     234  "Matches against all of the string.");
     235  
     236  #define _SRE_SRE_PATTERN_FULLMATCH_METHODDEF    \
     237      {"fullmatch", _PyCFunction_CAST(_sre_SRE_Pattern_fullmatch), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_fullmatch__doc__},
     238  
     239  static PyObject *
     240  _sre_SRE_Pattern_fullmatch_impl(PatternObject *self, PyTypeObject *cls,
     241                                  PyObject *string, Py_ssize_t pos,
     242                                  Py_ssize_t endpos);
     243  
     244  static PyObject *
     245  _sre_SRE_Pattern_fullmatch(PatternObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     246  {
     247      PyObject *return_value = NULL;
     248      static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
     249      static _PyArg_Parser _parser = {NULL, _keywords, "fullmatch", 0};
     250      PyObject *argsbuf[3];
     251      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
     252      PyObject *string;
     253      Py_ssize_t pos = 0;
     254      Py_ssize_t endpos = PY_SSIZE_T_MAX;
     255  
     256      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
     257      if (!args) {
     258          goto exit;
     259      }
     260      string = args[0];
     261      if (!noptargs) {
     262          goto skip_optional_pos;
     263      }
     264      if (args[1]) {
     265          {
     266              Py_ssize_t ival = -1;
     267              PyObject *iobj = _PyNumber_Index(args[1]);
     268              if (iobj != NULL) {
     269                  ival = PyLong_AsSsize_t(iobj);
     270                  Py_DECREF(iobj);
     271              }
     272              if (ival == -1 && PyErr_Occurred()) {
     273                  goto exit;
     274              }
     275              pos = ival;
     276          }
     277          if (!--noptargs) {
     278              goto skip_optional_pos;
     279          }
     280      }
     281      {
     282          Py_ssize_t ival = -1;
     283          PyObject *iobj = _PyNumber_Index(args[2]);
     284          if (iobj != NULL) {
     285              ival = PyLong_AsSsize_t(iobj);
     286              Py_DECREF(iobj);
     287          }
     288          if (ival == -1 && PyErr_Occurred()) {
     289              goto exit;
     290          }
     291          endpos = ival;
     292      }
     293  skip_optional_pos:
     294      return_value = _sre_SRE_Pattern_fullmatch_impl(self, cls, string, pos, endpos);
     295  
     296  exit:
     297      return return_value;
     298  }
     299  
     300  PyDoc_STRVAR(_sre_SRE_Pattern_search__doc__,
     301  "search($self, /, string, pos=0, endpos=sys.maxsize)\n"
     302  "--\n"
     303  "\n"
     304  "Scan through string looking for a match, and return a corresponding match object instance.\n"
     305  "\n"
     306  "Return None if no position in the string matches.");
     307  
     308  #define _SRE_SRE_PATTERN_SEARCH_METHODDEF    \
     309      {"search", _PyCFunction_CAST(_sre_SRE_Pattern_search), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_search__doc__},
     310  
     311  static PyObject *
     312  _sre_SRE_Pattern_search_impl(PatternObject *self, PyTypeObject *cls,
     313                               PyObject *string, Py_ssize_t pos,
     314                               Py_ssize_t endpos);
     315  
     316  static PyObject *
     317  _sre_SRE_Pattern_search(PatternObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     318  {
     319      PyObject *return_value = NULL;
     320      static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
     321      static _PyArg_Parser _parser = {NULL, _keywords, "search", 0};
     322      PyObject *argsbuf[3];
     323      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
     324      PyObject *string;
     325      Py_ssize_t pos = 0;
     326      Py_ssize_t endpos = PY_SSIZE_T_MAX;
     327  
     328      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
     329      if (!args) {
     330          goto exit;
     331      }
     332      string = args[0];
     333      if (!noptargs) {
     334          goto skip_optional_pos;
     335      }
     336      if (args[1]) {
     337          {
     338              Py_ssize_t ival = -1;
     339              PyObject *iobj = _PyNumber_Index(args[1]);
     340              if (iobj != NULL) {
     341                  ival = PyLong_AsSsize_t(iobj);
     342                  Py_DECREF(iobj);
     343              }
     344              if (ival == -1 && PyErr_Occurred()) {
     345                  goto exit;
     346              }
     347              pos = ival;
     348          }
     349          if (!--noptargs) {
     350              goto skip_optional_pos;
     351          }
     352      }
     353      {
     354          Py_ssize_t ival = -1;
     355          PyObject *iobj = _PyNumber_Index(args[2]);
     356          if (iobj != NULL) {
     357              ival = PyLong_AsSsize_t(iobj);
     358              Py_DECREF(iobj);
     359          }
     360          if (ival == -1 && PyErr_Occurred()) {
     361              goto exit;
     362          }
     363          endpos = ival;
     364      }
     365  skip_optional_pos:
     366      return_value = _sre_SRE_Pattern_search_impl(self, cls, string, pos, endpos);
     367  
     368  exit:
     369      return return_value;
     370  }
     371  
     372  PyDoc_STRVAR(_sre_SRE_Pattern_findall__doc__,
     373  "findall($self, /, string, pos=0, endpos=sys.maxsize)\n"
     374  "--\n"
     375  "\n"
     376  "Return a list of all non-overlapping matches of pattern in string.");
     377  
     378  #define _SRE_SRE_PATTERN_FINDALL_METHODDEF    \
     379      {"findall", _PyCFunction_CAST(_sre_SRE_Pattern_findall), METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_findall__doc__},
     380  
     381  static PyObject *
     382  _sre_SRE_Pattern_findall_impl(PatternObject *self, PyObject *string,
     383                                Py_ssize_t pos, Py_ssize_t endpos);
     384  
     385  static PyObject *
     386  _sre_SRE_Pattern_findall(PatternObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     387  {
     388      PyObject *return_value = NULL;
     389      static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
     390      static _PyArg_Parser _parser = {NULL, _keywords, "findall", 0};
     391      PyObject *argsbuf[3];
     392      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
     393      PyObject *string;
     394      Py_ssize_t pos = 0;
     395      Py_ssize_t endpos = PY_SSIZE_T_MAX;
     396  
     397      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
     398      if (!args) {
     399          goto exit;
     400      }
     401      string = args[0];
     402      if (!noptargs) {
     403          goto skip_optional_pos;
     404      }
     405      if (args[1]) {
     406          {
     407              Py_ssize_t ival = -1;
     408              PyObject *iobj = _PyNumber_Index(args[1]);
     409              if (iobj != NULL) {
     410                  ival = PyLong_AsSsize_t(iobj);
     411                  Py_DECREF(iobj);
     412              }
     413              if (ival == -1 && PyErr_Occurred()) {
     414                  goto exit;
     415              }
     416              pos = ival;
     417          }
     418          if (!--noptargs) {
     419              goto skip_optional_pos;
     420          }
     421      }
     422      {
     423          Py_ssize_t ival = -1;
     424          PyObject *iobj = _PyNumber_Index(args[2]);
     425          if (iobj != NULL) {
     426              ival = PyLong_AsSsize_t(iobj);
     427              Py_DECREF(iobj);
     428          }
     429          if (ival == -1 && PyErr_Occurred()) {
     430              goto exit;
     431          }
     432          endpos = ival;
     433      }
     434  skip_optional_pos:
     435      return_value = _sre_SRE_Pattern_findall_impl(self, string, pos, endpos);
     436  
     437  exit:
     438      return return_value;
     439  }
     440  
     441  PyDoc_STRVAR(_sre_SRE_Pattern_finditer__doc__,
     442  "finditer($self, /, string, pos=0, endpos=sys.maxsize)\n"
     443  "--\n"
     444  "\n"
     445  "Return an iterator over all non-overlapping matches for the RE pattern in string.\n"
     446  "\n"
     447  "For each match, the iterator returns a match object.");
     448  
     449  #define _SRE_SRE_PATTERN_FINDITER_METHODDEF    \
     450      {"finditer", _PyCFunction_CAST(_sre_SRE_Pattern_finditer), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_finditer__doc__},
     451  
     452  static PyObject *
     453  _sre_SRE_Pattern_finditer_impl(PatternObject *self, PyTypeObject *cls,
     454                                 PyObject *string, Py_ssize_t pos,
     455                                 Py_ssize_t endpos);
     456  
     457  static PyObject *
     458  _sre_SRE_Pattern_finditer(PatternObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     459  {
     460      PyObject *return_value = NULL;
     461      static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
     462      static _PyArg_Parser _parser = {NULL, _keywords, "finditer", 0};
     463      PyObject *argsbuf[3];
     464      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
     465      PyObject *string;
     466      Py_ssize_t pos = 0;
     467      Py_ssize_t endpos = PY_SSIZE_T_MAX;
     468  
     469      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
     470      if (!args) {
     471          goto exit;
     472      }
     473      string = args[0];
     474      if (!noptargs) {
     475          goto skip_optional_pos;
     476      }
     477      if (args[1]) {
     478          {
     479              Py_ssize_t ival = -1;
     480              PyObject *iobj = _PyNumber_Index(args[1]);
     481              if (iobj != NULL) {
     482                  ival = PyLong_AsSsize_t(iobj);
     483                  Py_DECREF(iobj);
     484              }
     485              if (ival == -1 && PyErr_Occurred()) {
     486                  goto exit;
     487              }
     488              pos = ival;
     489          }
     490          if (!--noptargs) {
     491              goto skip_optional_pos;
     492          }
     493      }
     494      {
     495          Py_ssize_t ival = -1;
     496          PyObject *iobj = _PyNumber_Index(args[2]);
     497          if (iobj != NULL) {
     498              ival = PyLong_AsSsize_t(iobj);
     499              Py_DECREF(iobj);
     500          }
     501          if (ival == -1 && PyErr_Occurred()) {
     502              goto exit;
     503          }
     504          endpos = ival;
     505      }
     506  skip_optional_pos:
     507      return_value = _sre_SRE_Pattern_finditer_impl(self, cls, string, pos, endpos);
     508  
     509  exit:
     510      return return_value;
     511  }
     512  
     513  PyDoc_STRVAR(_sre_SRE_Pattern_scanner__doc__,
     514  "scanner($self, /, string, pos=0, endpos=sys.maxsize)\n"
     515  "--\n"
     516  "\n");
     517  
     518  #define _SRE_SRE_PATTERN_SCANNER_METHODDEF    \
     519      {"scanner", _PyCFunction_CAST(_sre_SRE_Pattern_scanner), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_scanner__doc__},
     520  
     521  static PyObject *
     522  _sre_SRE_Pattern_scanner_impl(PatternObject *self, PyTypeObject *cls,
     523                                PyObject *string, Py_ssize_t pos,
     524                                Py_ssize_t endpos);
     525  
     526  static PyObject *
     527  _sre_SRE_Pattern_scanner(PatternObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     528  {
     529      PyObject *return_value = NULL;
     530      static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
     531      static _PyArg_Parser _parser = {NULL, _keywords, "scanner", 0};
     532      PyObject *argsbuf[3];
     533      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
     534      PyObject *string;
     535      Py_ssize_t pos = 0;
     536      Py_ssize_t endpos = PY_SSIZE_T_MAX;
     537  
     538      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
     539      if (!args) {
     540          goto exit;
     541      }
     542      string = args[0];
     543      if (!noptargs) {
     544          goto skip_optional_pos;
     545      }
     546      if (args[1]) {
     547          {
     548              Py_ssize_t ival = -1;
     549              PyObject *iobj = _PyNumber_Index(args[1]);
     550              if (iobj != NULL) {
     551                  ival = PyLong_AsSsize_t(iobj);
     552                  Py_DECREF(iobj);
     553              }
     554              if (ival == -1 && PyErr_Occurred()) {
     555                  goto exit;
     556              }
     557              pos = ival;
     558          }
     559          if (!--noptargs) {
     560              goto skip_optional_pos;
     561          }
     562      }
     563      {
     564          Py_ssize_t ival = -1;
     565          PyObject *iobj = _PyNumber_Index(args[2]);
     566          if (iobj != NULL) {
     567              ival = PyLong_AsSsize_t(iobj);
     568              Py_DECREF(iobj);
     569          }
     570          if (ival == -1 && PyErr_Occurred()) {
     571              goto exit;
     572          }
     573          endpos = ival;
     574      }
     575  skip_optional_pos:
     576      return_value = _sre_SRE_Pattern_scanner_impl(self, cls, string, pos, endpos);
     577  
     578  exit:
     579      return return_value;
     580  }
     581  
     582  PyDoc_STRVAR(_sre_SRE_Pattern_split__doc__,
     583  "split($self, /, string, maxsplit=0)\n"
     584  "--\n"
     585  "\n"
     586  "Split string by the occurrences of pattern.");
     587  
     588  #define _SRE_SRE_PATTERN_SPLIT_METHODDEF    \
     589      {"split", _PyCFunction_CAST(_sre_SRE_Pattern_split), METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_split__doc__},
     590  
     591  static PyObject *
     592  _sre_SRE_Pattern_split_impl(PatternObject *self, PyObject *string,
     593                              Py_ssize_t maxsplit);
     594  
     595  static PyObject *
     596  _sre_SRE_Pattern_split(PatternObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     597  {
     598      PyObject *return_value = NULL;
     599      static const char * const _keywords[] = {"string", "maxsplit", NULL};
     600      static _PyArg_Parser _parser = {NULL, _keywords, "split", 0};
     601      PyObject *argsbuf[2];
     602      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
     603      PyObject *string;
     604      Py_ssize_t maxsplit = 0;
     605  
     606      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
     607      if (!args) {
     608          goto exit;
     609      }
     610      string = args[0];
     611      if (!noptargs) {
     612          goto skip_optional_pos;
     613      }
     614      {
     615          Py_ssize_t ival = -1;
     616          PyObject *iobj = _PyNumber_Index(args[1]);
     617          if (iobj != NULL) {
     618              ival = PyLong_AsSsize_t(iobj);
     619              Py_DECREF(iobj);
     620          }
     621          if (ival == -1 && PyErr_Occurred()) {
     622              goto exit;
     623          }
     624          maxsplit = ival;
     625      }
     626  skip_optional_pos:
     627      return_value = _sre_SRE_Pattern_split_impl(self, string, maxsplit);
     628  
     629  exit:
     630      return return_value;
     631  }
     632  
     633  PyDoc_STRVAR(_sre_SRE_Pattern_sub__doc__,
     634  "sub($self, /, repl, string, count=0)\n"
     635  "--\n"
     636  "\n"
     637  "Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl.");
     638  
     639  #define _SRE_SRE_PATTERN_SUB_METHODDEF    \
     640      {"sub", _PyCFunction_CAST(_sre_SRE_Pattern_sub), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_sub__doc__},
     641  
     642  static PyObject *
     643  _sre_SRE_Pattern_sub_impl(PatternObject *self, PyTypeObject *cls,
     644                            PyObject *repl, PyObject *string, Py_ssize_t count);
     645  
     646  static PyObject *
     647  _sre_SRE_Pattern_sub(PatternObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     648  {
     649      PyObject *return_value = NULL;
     650      static const char * const _keywords[] = {"repl", "string", "count", NULL};
     651      static _PyArg_Parser _parser = {NULL, _keywords, "sub", 0};
     652      PyObject *argsbuf[3];
     653      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
     654      PyObject *repl;
     655      PyObject *string;
     656      Py_ssize_t count = 0;
     657  
     658      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf);
     659      if (!args) {
     660          goto exit;
     661      }
     662      repl = args[0];
     663      string = args[1];
     664      if (!noptargs) {
     665          goto skip_optional_pos;
     666      }
     667      {
     668          Py_ssize_t ival = -1;
     669          PyObject *iobj = _PyNumber_Index(args[2]);
     670          if (iobj != NULL) {
     671              ival = PyLong_AsSsize_t(iobj);
     672              Py_DECREF(iobj);
     673          }
     674          if (ival == -1 && PyErr_Occurred()) {
     675              goto exit;
     676          }
     677          count = ival;
     678      }
     679  skip_optional_pos:
     680      return_value = _sre_SRE_Pattern_sub_impl(self, cls, repl, string, count);
     681  
     682  exit:
     683      return return_value;
     684  }
     685  
     686  PyDoc_STRVAR(_sre_SRE_Pattern_subn__doc__,
     687  "subn($self, /, repl, string, count=0)\n"
     688  "--\n"
     689  "\n"
     690  "Return the tuple (new_string, number_of_subs_made) found by replacing the leftmost non-overlapping occurrences of pattern with the replacement repl.");
     691  
     692  #define _SRE_SRE_PATTERN_SUBN_METHODDEF    \
     693      {"subn", _PyCFunction_CAST(_sre_SRE_Pattern_subn), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_subn__doc__},
     694  
     695  static PyObject *
     696  _sre_SRE_Pattern_subn_impl(PatternObject *self, PyTypeObject *cls,
     697                             PyObject *repl, PyObject *string,
     698                             Py_ssize_t count);
     699  
     700  static PyObject *
     701  _sre_SRE_Pattern_subn(PatternObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     702  {
     703      PyObject *return_value = NULL;
     704      static const char * const _keywords[] = {"repl", "string", "count", NULL};
     705      static _PyArg_Parser _parser = {NULL, _keywords, "subn", 0};
     706      PyObject *argsbuf[3];
     707      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
     708      PyObject *repl;
     709      PyObject *string;
     710      Py_ssize_t count = 0;
     711  
     712      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf);
     713      if (!args) {
     714          goto exit;
     715      }
     716      repl = args[0];
     717      string = args[1];
     718      if (!noptargs) {
     719          goto skip_optional_pos;
     720      }
     721      {
     722          Py_ssize_t ival = -1;
     723          PyObject *iobj = _PyNumber_Index(args[2]);
     724          if (iobj != NULL) {
     725              ival = PyLong_AsSsize_t(iobj);
     726              Py_DECREF(iobj);
     727          }
     728          if (ival == -1 && PyErr_Occurred()) {
     729              goto exit;
     730          }
     731          count = ival;
     732      }
     733  skip_optional_pos:
     734      return_value = _sre_SRE_Pattern_subn_impl(self, cls, repl, string, count);
     735  
     736  exit:
     737      return return_value;
     738  }
     739  
     740  PyDoc_STRVAR(_sre_SRE_Pattern___copy____doc__,
     741  "__copy__($self, /)\n"
     742  "--\n"
     743  "\n");
     744  
     745  #define _SRE_SRE_PATTERN___COPY___METHODDEF    \
     746      {"__copy__", (PyCFunction)_sre_SRE_Pattern___copy__, METH_NOARGS, _sre_SRE_Pattern___copy____doc__},
     747  
     748  static PyObject *
     749  _sre_SRE_Pattern___copy___impl(PatternObject *self);
     750  
     751  static PyObject *
     752  _sre_SRE_Pattern___copy__(PatternObject *self, PyObject *Py_UNUSED(ignored))
     753  {
     754      return _sre_SRE_Pattern___copy___impl(self);
     755  }
     756  
     757  PyDoc_STRVAR(_sre_SRE_Pattern___deepcopy____doc__,
     758  "__deepcopy__($self, memo, /)\n"
     759  "--\n"
     760  "\n");
     761  
     762  #define _SRE_SRE_PATTERN___DEEPCOPY___METHODDEF    \
     763      {"__deepcopy__", (PyCFunction)_sre_SRE_Pattern___deepcopy__, METH_O, _sre_SRE_Pattern___deepcopy____doc__},
     764  
     765  PyDoc_STRVAR(_sre_compile__doc__,
     766  "compile($module, /, pattern, flags, code, groups, groupindex,\n"
     767  "        indexgroup)\n"
     768  "--\n"
     769  "\n");
     770  
     771  #define _SRE_COMPILE_METHODDEF    \
     772      {"compile", _PyCFunction_CAST(_sre_compile), METH_FASTCALL|METH_KEYWORDS, _sre_compile__doc__},
     773  
     774  static PyObject *
     775  _sre_compile_impl(PyObject *module, PyObject *pattern, int flags,
     776                    PyObject *code, Py_ssize_t groups, PyObject *groupindex,
     777                    PyObject *indexgroup);
     778  
     779  static PyObject *
     780  _sre_compile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     781  {
     782      PyObject *return_value = NULL;
     783      static const char * const _keywords[] = {"pattern", "flags", "code", "groups", "groupindex", "indexgroup", NULL};
     784      static _PyArg_Parser _parser = {NULL, _keywords, "compile", 0};
     785      PyObject *argsbuf[6];
     786      PyObject *pattern;
     787      int flags;
     788      PyObject *code;
     789      Py_ssize_t groups;
     790      PyObject *groupindex;
     791      PyObject *indexgroup;
     792  
     793      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 6, 6, 0, argsbuf);
     794      if (!args) {
     795          goto exit;
     796      }
     797      pattern = args[0];
     798      flags = _PyLong_AsInt(args[1]);
     799      if (flags == -1 && PyErr_Occurred()) {
     800          goto exit;
     801      }
     802      if (!PyList_Check(args[2])) {
     803          _PyArg_BadArgument("compile", "argument 'code'", "list", args[2]);
     804          goto exit;
     805      }
     806      code = args[2];
     807      {
     808          Py_ssize_t ival = -1;
     809          PyObject *iobj = _PyNumber_Index(args[3]);
     810          if (iobj != NULL) {
     811              ival = PyLong_AsSsize_t(iobj);
     812              Py_DECREF(iobj);
     813          }
     814          if (ival == -1 && PyErr_Occurred()) {
     815              goto exit;
     816          }
     817          groups = ival;
     818      }
     819      if (!PyDict_Check(args[4])) {
     820          _PyArg_BadArgument("compile", "argument 'groupindex'", "dict", args[4]);
     821          goto exit;
     822      }
     823      groupindex = args[4];
     824      if (!PyTuple_Check(args[5])) {
     825          _PyArg_BadArgument("compile", "argument 'indexgroup'", "tuple", args[5]);
     826          goto exit;
     827      }
     828      indexgroup = args[5];
     829      return_value = _sre_compile_impl(module, pattern, flags, code, groups, groupindex, indexgroup);
     830  
     831  exit:
     832      return return_value;
     833  }
     834  
     835  PyDoc_STRVAR(_sre_SRE_Match_expand__doc__,
     836  "expand($self, /, template)\n"
     837  "--\n"
     838  "\n"
     839  "Return the string obtained by doing backslash substitution on the string template, as done by the sub() method.");
     840  
     841  #define _SRE_SRE_MATCH_EXPAND_METHODDEF    \
     842      {"expand", _PyCFunction_CAST(_sre_SRE_Match_expand), METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Match_expand__doc__},
     843  
     844  static PyObject *
     845  _sre_SRE_Match_expand_impl(MatchObject *self, PyObject *template);
     846  
     847  static PyObject *
     848  _sre_SRE_Match_expand(MatchObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     849  {
     850      PyObject *return_value = NULL;
     851      static const char * const _keywords[] = {"template", NULL};
     852      static _PyArg_Parser _parser = {NULL, _keywords, "expand", 0};
     853      PyObject *argsbuf[1];
     854      PyObject *template;
     855  
     856      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
     857      if (!args) {
     858          goto exit;
     859      }
     860      template = args[0];
     861      return_value = _sre_SRE_Match_expand_impl(self, template);
     862  
     863  exit:
     864      return return_value;
     865  }
     866  
     867  PyDoc_STRVAR(_sre_SRE_Match_groups__doc__,
     868  "groups($self, /, default=None)\n"
     869  "--\n"
     870  "\n"
     871  "Return a tuple containing all the subgroups of the match, from 1.\n"
     872  "\n"
     873  "  default\n"
     874  "    Is used for groups that did not participate in the match.");
     875  
     876  #define _SRE_SRE_MATCH_GROUPS_METHODDEF    \
     877      {"groups", _PyCFunction_CAST(_sre_SRE_Match_groups), METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Match_groups__doc__},
     878  
     879  static PyObject *
     880  _sre_SRE_Match_groups_impl(MatchObject *self, PyObject *default_value);
     881  
     882  static PyObject *
     883  _sre_SRE_Match_groups(MatchObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     884  {
     885      PyObject *return_value = NULL;
     886      static const char * const _keywords[] = {"default", NULL};
     887      static _PyArg_Parser _parser = {NULL, _keywords, "groups", 0};
     888      PyObject *argsbuf[1];
     889      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     890      PyObject *default_value = Py_None;
     891  
     892      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
     893      if (!args) {
     894          goto exit;
     895      }
     896      if (!noptargs) {
     897          goto skip_optional_pos;
     898      }
     899      default_value = args[0];
     900  skip_optional_pos:
     901      return_value = _sre_SRE_Match_groups_impl(self, default_value);
     902  
     903  exit:
     904      return return_value;
     905  }
     906  
     907  PyDoc_STRVAR(_sre_SRE_Match_groupdict__doc__,
     908  "groupdict($self, /, default=None)\n"
     909  "--\n"
     910  "\n"
     911  "Return a dictionary containing all the named subgroups of the match, keyed by the subgroup name.\n"
     912  "\n"
     913  "  default\n"
     914  "    Is used for groups that did not participate in the match.");
     915  
     916  #define _SRE_SRE_MATCH_GROUPDICT_METHODDEF    \
     917      {"groupdict", _PyCFunction_CAST(_sre_SRE_Match_groupdict), METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Match_groupdict__doc__},
     918  
     919  static PyObject *
     920  _sre_SRE_Match_groupdict_impl(MatchObject *self, PyObject *default_value);
     921  
     922  static PyObject *
     923  _sre_SRE_Match_groupdict(MatchObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     924  {
     925      PyObject *return_value = NULL;
     926      static const char * const _keywords[] = {"default", NULL};
     927      static _PyArg_Parser _parser = {NULL, _keywords, "groupdict", 0};
     928      PyObject *argsbuf[1];
     929      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     930      PyObject *default_value = Py_None;
     931  
     932      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
     933      if (!args) {
     934          goto exit;
     935      }
     936      if (!noptargs) {
     937          goto skip_optional_pos;
     938      }
     939      default_value = args[0];
     940  skip_optional_pos:
     941      return_value = _sre_SRE_Match_groupdict_impl(self, default_value);
     942  
     943  exit:
     944      return return_value;
     945  }
     946  
     947  PyDoc_STRVAR(_sre_SRE_Match_start__doc__,
     948  "start($self, group=0, /)\n"
     949  "--\n"
     950  "\n"
     951  "Return index of the start of the substring matched by group.");
     952  
     953  #define _SRE_SRE_MATCH_START_METHODDEF    \
     954      {"start", _PyCFunction_CAST(_sre_SRE_Match_start), METH_FASTCALL, _sre_SRE_Match_start__doc__},
     955  
     956  static Py_ssize_t
     957  _sre_SRE_Match_start_impl(MatchObject *self, PyObject *group);
     958  
     959  static PyObject *
     960  _sre_SRE_Match_start(MatchObject *self, PyObject *const *args, Py_ssize_t nargs)
     961  {
     962      PyObject *return_value = NULL;
     963      PyObject *group = NULL;
     964      Py_ssize_t _return_value;
     965  
     966      if (!_PyArg_CheckPositional("start", nargs, 0, 1)) {
     967          goto exit;
     968      }
     969      if (nargs < 1) {
     970          goto skip_optional;
     971      }
     972      group = args[0];
     973  skip_optional:
     974      _return_value = _sre_SRE_Match_start_impl(self, group);
     975      if ((_return_value == -1) && PyErr_Occurred()) {
     976          goto exit;
     977      }
     978      return_value = PyLong_FromSsize_t(_return_value);
     979  
     980  exit:
     981      return return_value;
     982  }
     983  
     984  PyDoc_STRVAR(_sre_SRE_Match_end__doc__,
     985  "end($self, group=0, /)\n"
     986  "--\n"
     987  "\n"
     988  "Return index of the end of the substring matched by group.");
     989  
     990  #define _SRE_SRE_MATCH_END_METHODDEF    \
     991      {"end", _PyCFunction_CAST(_sre_SRE_Match_end), METH_FASTCALL, _sre_SRE_Match_end__doc__},
     992  
     993  static Py_ssize_t
     994  _sre_SRE_Match_end_impl(MatchObject *self, PyObject *group);
     995  
     996  static PyObject *
     997  _sre_SRE_Match_end(MatchObject *self, PyObject *const *args, Py_ssize_t nargs)
     998  {
     999      PyObject *return_value = NULL;
    1000      PyObject *group = NULL;
    1001      Py_ssize_t _return_value;
    1002  
    1003      if (!_PyArg_CheckPositional("end", nargs, 0, 1)) {
    1004          goto exit;
    1005      }
    1006      if (nargs < 1) {
    1007          goto skip_optional;
    1008      }
    1009      group = args[0];
    1010  skip_optional:
    1011      _return_value = _sre_SRE_Match_end_impl(self, group);
    1012      if ((_return_value == -1) && PyErr_Occurred()) {
    1013          goto exit;
    1014      }
    1015      return_value = PyLong_FromSsize_t(_return_value);
    1016  
    1017  exit:
    1018      return return_value;
    1019  }
    1020  
    1021  PyDoc_STRVAR(_sre_SRE_Match_span__doc__,
    1022  "span($self, group=0, /)\n"
    1023  "--\n"
    1024  "\n"
    1025  "For match object m, return the 2-tuple (m.start(group), m.end(group)).");
    1026  
    1027  #define _SRE_SRE_MATCH_SPAN_METHODDEF    \
    1028      {"span", _PyCFunction_CAST(_sre_SRE_Match_span), METH_FASTCALL, _sre_SRE_Match_span__doc__},
    1029  
    1030  static PyObject *
    1031  _sre_SRE_Match_span_impl(MatchObject *self, PyObject *group);
    1032  
    1033  static PyObject *
    1034  _sre_SRE_Match_span(MatchObject *self, PyObject *const *args, Py_ssize_t nargs)
    1035  {
    1036      PyObject *return_value = NULL;
    1037      PyObject *group = NULL;
    1038  
    1039      if (!_PyArg_CheckPositional("span", nargs, 0, 1)) {
    1040          goto exit;
    1041      }
    1042      if (nargs < 1) {
    1043          goto skip_optional;
    1044      }
    1045      group = args[0];
    1046  skip_optional:
    1047      return_value = _sre_SRE_Match_span_impl(self, group);
    1048  
    1049  exit:
    1050      return return_value;
    1051  }
    1052  
    1053  PyDoc_STRVAR(_sre_SRE_Match___copy____doc__,
    1054  "__copy__($self, /)\n"
    1055  "--\n"
    1056  "\n");
    1057  
    1058  #define _SRE_SRE_MATCH___COPY___METHODDEF    \
    1059      {"__copy__", (PyCFunction)_sre_SRE_Match___copy__, METH_NOARGS, _sre_SRE_Match___copy____doc__},
    1060  
    1061  static PyObject *
    1062  _sre_SRE_Match___copy___impl(MatchObject *self);
    1063  
    1064  static PyObject *
    1065  _sre_SRE_Match___copy__(MatchObject *self, PyObject *Py_UNUSED(ignored))
    1066  {
    1067      return _sre_SRE_Match___copy___impl(self);
    1068  }
    1069  
    1070  PyDoc_STRVAR(_sre_SRE_Match___deepcopy____doc__,
    1071  "__deepcopy__($self, memo, /)\n"
    1072  "--\n"
    1073  "\n");
    1074  
    1075  #define _SRE_SRE_MATCH___DEEPCOPY___METHODDEF    \
    1076      {"__deepcopy__", (PyCFunction)_sre_SRE_Match___deepcopy__, METH_O, _sre_SRE_Match___deepcopy____doc__},
    1077  
    1078  PyDoc_STRVAR(_sre_SRE_Scanner_match__doc__,
    1079  "match($self, /)\n"
    1080  "--\n"
    1081  "\n");
    1082  
    1083  #define _SRE_SRE_SCANNER_MATCH_METHODDEF    \
    1084      {"match", _PyCFunction_CAST(_sre_SRE_Scanner_match), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Scanner_match__doc__},
    1085  
    1086  static PyObject *
    1087  _sre_SRE_Scanner_match_impl(ScannerObject *self, PyTypeObject *cls);
    1088  
    1089  static PyObject *
    1090  _sre_SRE_Scanner_match(ScannerObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
    1091  {
    1092      if (nargs) {
    1093          PyErr_SetString(PyExc_TypeError, "match() takes no arguments");
    1094          return NULL;
    1095      }
    1096      return _sre_SRE_Scanner_match_impl(self, cls);
    1097  }
    1098  
    1099  PyDoc_STRVAR(_sre_SRE_Scanner_search__doc__,
    1100  "search($self, /)\n"
    1101  "--\n"
    1102  "\n");
    1103  
    1104  #define _SRE_SRE_SCANNER_SEARCH_METHODDEF    \
    1105      {"search", _PyCFunction_CAST(_sre_SRE_Scanner_search), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Scanner_search__doc__},
    1106  
    1107  static PyObject *
    1108  _sre_SRE_Scanner_search_impl(ScannerObject *self, PyTypeObject *cls);
    1109  
    1110  static PyObject *
    1111  _sre_SRE_Scanner_search(ScannerObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
    1112  {
    1113      if (nargs) {
    1114          PyErr_SetString(PyExc_TypeError, "search() takes no arguments");
    1115          return NULL;
    1116      }
    1117      return _sre_SRE_Scanner_search_impl(self, cls);
    1118  }
    1119  /*[clinic end generated code: output=fd2f45c941620e6e input=a9049054013a1b77]*/