Coverage Report

Created: 2026-10-31 06:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cpython/Modules/_sre/clinic/sre.c.h
Line
Count
Source
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_abstract.h"      // _PyNumber_Index()
10
#include "pycore_modsupport.h"    // _PyArg_UnpackKeywords()
11
12
PyDoc_STRVAR(_sre_getcodesize__doc__,
13
"getcodesize($module, /)\n"
14
"--\n"
15
"\n");
16
17
#define _SRE_GETCODESIZE_METHODDEF    \
18
    {"getcodesize", (PyCFunction)_sre_getcodesize, METH_NOARGS, _sre_getcodesize__doc__},
19
20
static int
21
_sre_getcodesize_impl(PyObject *module);
22
23
static PyObject *
24
_sre_getcodesize(PyObject *module, PyObject *Py_UNUSED(ignored))
25
0
{
26
0
    PyObject *return_value = NULL;
27
0
    int _return_value;
28
29
0
    _return_value = _sre_getcodesize_impl(module);
30
0
    if ((_return_value == -1) && PyErr_Occurred()) {
31
0
        goto exit;
32
0
    }
33
0
    return_value = PyLong_FromLong((long)_return_value);
34
35
0
exit:
36
0
    return return_value;
37
0
}
38
39
PyDoc_STRVAR(_sre_ascii_iscased__doc__,
40
"ascii_iscased($module, character, /)\n"
41
"--\n"
42
"\n");
43
44
#define _SRE_ASCII_ISCASED_METHODDEF    \
45
    {"ascii_iscased", (PyCFunction)_sre_ascii_iscased, METH_O, _sre_ascii_iscased__doc__},
46
47
static int
48
_sre_ascii_iscased_impl(PyObject *module, int character);
49
50
static PyObject *
51
_sre_ascii_iscased(PyObject *module, PyObject *arg)
52
323k
{
53
323k
    PyObject *return_value = NULL;
54
323k
    int character;
55
323k
    int _return_value;
56
57
323k
    character = PyLong_AsInt(arg);
58
323k
    if (character == -1 && PyErr_Occurred()) {
59
0
        goto exit;
60
0
    }
61
323k
    _return_value = _sre_ascii_iscased_impl(module, character);
62
323k
    if ((_return_value == -1) && PyErr_Occurred()) {
63
0
        goto exit;
64
0
    }
65
323k
    return_value = PyBool_FromLong((long)_return_value);
66
67
323k
exit:
68
323k
    return return_value;
69
323k
}
70
71
PyDoc_STRVAR(_sre_unicode_iscased__doc__,
72
"unicode_iscased($module, character, /)\n"
73
"--\n"
74
"\n");
75
76
#define _SRE_UNICODE_ISCASED_METHODDEF    \
77
    {"unicode_iscased", (PyCFunction)_sre_unicode_iscased, METH_O, _sre_unicode_iscased__doc__},
78
79
static int
80
_sre_unicode_iscased_impl(PyObject *module, int character);
81
82
static PyObject *
83
_sre_unicode_iscased(PyObject *module, PyObject *arg)
84
21.0M
{
85
21.0M
    PyObject *return_value = NULL;
86
21.0M
    int character;
87
21.0M
    int _return_value;
88
89
21.0M
    character = PyLong_AsInt(arg);
90
21.0M
    if (character == -1 && PyErr_Occurred()) {
91
0
        goto exit;
92
0
    }
93
21.0M
    _return_value = _sre_unicode_iscased_impl(module, character);
94
21.0M
    if ((_return_value == -1) && PyErr_Occurred()) {
95
0
        goto exit;
96
0
    }
97
21.0M
    return_value = PyBool_FromLong((long)_return_value);
98
99
21.0M
exit:
100
21.0M
    return return_value;
101
21.0M
}
102
103
PyDoc_STRVAR(_sre_ascii_tolower__doc__,
104
"ascii_tolower($module, character, /)\n"
105
"--\n"
106
"\n");
107
108
#define _SRE_ASCII_TOLOWER_METHODDEF    \
109
    {"ascii_tolower", (PyCFunction)_sre_ascii_tolower, METH_O, _sre_ascii_tolower__doc__},
110
111
static int
112
_sre_ascii_tolower_impl(PyObject *module, int character);
113
114
static PyObject *
115
_sre_ascii_tolower(PyObject *module, PyObject *arg)
116
1.10M
{
117
1.10M
    PyObject *return_value = NULL;
118
1.10M
    int character;
119
1.10M
    int _return_value;
120
121
1.10M
    character = PyLong_AsInt(arg);
122
1.10M
    if (character == -1 && PyErr_Occurred()) {
123
0
        goto exit;
124
0
    }
125
1.10M
    _return_value = _sre_ascii_tolower_impl(module, character);
126
1.10M
    if ((_return_value == -1) && PyErr_Occurred()) {
127
0
        goto exit;
128
0
    }
129
1.10M
    return_value = PyLong_FromLong((long)_return_value);
130
131
1.10M
exit:
132
1.10M
    return return_value;
133
1.10M
}
134
135
PyDoc_STRVAR(_sre_unicode_tolower__doc__,
136
"unicode_tolower($module, character, /)\n"
137
"--\n"
138
"\n");
139
140
#define _SRE_UNICODE_TOLOWER_METHODDEF    \
141
    {"unicode_tolower", (PyCFunction)_sre_unicode_tolower, METH_O, _sre_unicode_tolower__doc__},
142
143
static int
144
_sre_unicode_tolower_impl(PyObject *module, int character);
145
146
static PyObject *
147
_sre_unicode_tolower(PyObject *module, PyObject *arg)
148
76.1M
{
149
76.1M
    PyObject *return_value = NULL;
150
76.1M
    int character;
151
76.1M
    int _return_value;
152
153
76.1M
    character = PyLong_AsInt(arg);
154
76.1M
    if (character == -1 && PyErr_Occurred()) {
155
0
        goto exit;
156
0
    }
157
76.1M
    _return_value = _sre_unicode_tolower_impl(module, character);
158
76.1M
    if ((_return_value == -1) && PyErr_Occurred()) {
159
0
        goto exit;
160
0
    }
161
76.1M
    return_value = PyLong_FromLong((long)_return_value);
162
163
76.1M
exit:
164
76.1M
    return return_value;
165
76.1M
}
166
167
PyDoc_STRVAR(_sre_SRE_Pattern_prefixmatch__doc__,
168
"prefixmatch($self, /, string, pos=0, endpos=sys.maxsize)\n"
169
"--\n"
170
"\n"
171
"Matches zero or more characters at the beginning of the string.");
172
173
#define _SRE_SRE_PATTERN_PREFIXMATCH_METHODDEF    \
174
    {"prefixmatch", _PyCFunction_CAST(_sre_SRE_Pattern_prefixmatch), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_prefixmatch__doc__},
175
176
static PyObject *
177
_sre_SRE_Pattern_prefixmatch_impl(PatternObject *self, PyTypeObject *cls,
178
                                  PyObject *string, Py_ssize_t pos,
179
                                  Py_ssize_t endpos);
180
181
static PyObject *
182
_sre_SRE_Pattern_prefixmatch(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
183
45.1M
{
184
45.1M
    PyObject *return_value = NULL;
185
45.1M
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
186
187
45.1M
    #define NUM_KEYWORDS 3
188
45.1M
    static struct {
189
45.1M
        PyGC_Head _this_is_not_used;
190
45.1M
        PyObject_VAR_HEAD
191
45.1M
        Py_hash_t ob_hash;
192
45.1M
        PyObject *ob_item[NUM_KEYWORDS];
193
45.1M
    } _kwtuple = {
194
45.1M
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
195
45.1M
        .ob_hash = -1,
196
45.1M
        .ob_item = { &_Py_ID(string), &_Py_ID(pos), &_Py_ID(endpos), },
197
45.1M
    };
198
45.1M
    #undef NUM_KEYWORDS
199
45.1M
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
200
201
    #else  // !Py_BUILD_CORE
202
    #  define KWTUPLE NULL
203
    #endif  // !Py_BUILD_CORE
204
205
45.1M
    static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
206
45.1M
    static _PyArg_Parser _parser = {
207
45.1M
        .keywords = _keywords,
208
45.1M
        .fname = "prefixmatch",
209
45.1M
        .kwtuple = KWTUPLE,
210
45.1M
    };
211
45.1M
    #undef KWTUPLE
212
45.1M
    PyObject *argsbuf[3];
213
45.1M
    Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
214
45.1M
    PyObject *string;
215
45.1M
    Py_ssize_t pos = 0;
216
45.1M
    Py_ssize_t endpos = PY_SSIZE_T_MAX;
217
218
45.1M
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
219
45.1M
            /*minpos*/ 1, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
220
45.1M
    if (!args) {
221
0
        goto exit;
222
0
    }
223
45.1M
    string = args[0];
224
45.1M
    if (!noptargs) {
225
41.4M
        goto skip_optional_pos;
226
41.4M
    }
227
3.67M
    if (args[1]) {
228
3.67M
        {
229
3.67M
            Py_ssize_t ival = -1;
230
3.67M
            PyObject *iobj = _PyNumber_Index(args[1]);
231
3.67M
            if (iobj != NULL) {
232
3.67M
                ival = PyLong_AsSsize_t(iobj);
233
3.67M
                Py_DECREF(iobj);
234
3.67M
            }
235
3.67M
            if (ival == -1 && PyErr_Occurred()) {
236
0
                goto exit;
237
0
            }
238
3.67M
            pos = ival;
239
3.67M
        }
240
3.67M
        if (!--noptargs) {
241
3.67M
            goto skip_optional_pos;
242
3.67M
        }
243
3.67M
    }
244
0
    {
245
0
        Py_ssize_t ival = -1;
246
0
        PyObject *iobj = _PyNumber_Index(args[2]);
247
0
        if (iobj != NULL) {
248
0
            ival = PyLong_AsSsize_t(iobj);
249
0
            Py_DECREF(iobj);
250
0
        }
251
0
        if (ival == -1 && PyErr_Occurred()) {
252
0
            goto exit;
253
0
        }
254
0
        endpos = ival;
255
0
    }
256
45.1M
skip_optional_pos:
257
45.1M
    return_value = _sre_SRE_Pattern_prefixmatch_impl((PatternObject *)self, cls, string, pos, endpos);
258
259
45.1M
exit:
260
45.1M
    return return_value;
261
45.1M
}
262
263
PyDoc_STRVAR(_sre_SRE_Pattern_fullmatch__doc__,
264
"fullmatch($self, /, string, pos=0, endpos=sys.maxsize)\n"
265
"--\n"
266
"\n"
267
"Matches against all of the string.");
268
269
#define _SRE_SRE_PATTERN_FULLMATCH_METHODDEF    \
270
    {"fullmatch", _PyCFunction_CAST(_sre_SRE_Pattern_fullmatch), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_fullmatch__doc__},
271
272
static PyObject *
273
_sre_SRE_Pattern_fullmatch_impl(PatternObject *self, PyTypeObject *cls,
274
                                PyObject *string, Py_ssize_t pos,
275
                                Py_ssize_t endpos);
276
277
static PyObject *
278
_sre_SRE_Pattern_fullmatch(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
279
22
{
280
22
    PyObject *return_value = NULL;
281
22
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
282
283
22
    #define NUM_KEYWORDS 3
284
22
    static struct {
285
22
        PyGC_Head _this_is_not_used;
286
22
        PyObject_VAR_HEAD
287
22
        Py_hash_t ob_hash;
288
22
        PyObject *ob_item[NUM_KEYWORDS];
289
22
    } _kwtuple = {
290
22
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
291
22
        .ob_hash = -1,
292
22
        .ob_item = { &_Py_ID(string), &_Py_ID(pos), &_Py_ID(endpos), },
293
22
    };
294
22
    #undef NUM_KEYWORDS
295
22
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
296
297
    #else  // !Py_BUILD_CORE
298
    #  define KWTUPLE NULL
299
    #endif  // !Py_BUILD_CORE
300
301
22
    static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
302
22
    static _PyArg_Parser _parser = {
303
22
        .keywords = _keywords,
304
22
        .fname = "fullmatch",
305
22
        .kwtuple = KWTUPLE,
306
22
    };
307
22
    #undef KWTUPLE
308
22
    PyObject *argsbuf[3];
309
22
    Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
310
22
    PyObject *string;
311
22
    Py_ssize_t pos = 0;
312
22
    Py_ssize_t endpos = PY_SSIZE_T_MAX;
313
314
22
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
315
22
            /*minpos*/ 1, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
316
22
    if (!args) {
317
0
        goto exit;
318
0
    }
319
22
    string = args[0];
320
22
    if (!noptargs) {
321
22
        goto skip_optional_pos;
322
22
    }
323
0
    if (args[1]) {
324
0
        {
325
0
            Py_ssize_t ival = -1;
326
0
            PyObject *iobj = _PyNumber_Index(args[1]);
327
0
            if (iobj != NULL) {
328
0
                ival = PyLong_AsSsize_t(iobj);
329
0
                Py_DECREF(iobj);
330
0
            }
331
0
            if (ival == -1 && PyErr_Occurred()) {
332
0
                goto exit;
333
0
            }
334
0
            pos = ival;
335
0
        }
336
0
        if (!--noptargs) {
337
0
            goto skip_optional_pos;
338
0
        }
339
0
    }
340
0
    {
341
0
        Py_ssize_t ival = -1;
342
0
        PyObject *iobj = _PyNumber_Index(args[2]);
343
0
        if (iobj != NULL) {
344
0
            ival = PyLong_AsSsize_t(iobj);
345
0
            Py_DECREF(iobj);
346
0
        }
347
0
        if (ival == -1 && PyErr_Occurred()) {
348
0
            goto exit;
349
0
        }
350
0
        endpos = ival;
351
0
    }
352
22
skip_optional_pos:
353
22
    return_value = _sre_SRE_Pattern_fullmatch_impl((PatternObject *)self, cls, string, pos, endpos);
354
355
22
exit:
356
22
    return return_value;
357
22
}
358
359
PyDoc_STRVAR(_sre_SRE_Pattern_search__doc__,
360
"search($self, /, string, pos=0, endpos=sys.maxsize)\n"
361
"--\n"
362
"\n"
363
"Scan through string looking for a match, and return a corresponding match object instance.\n"
364
"\n"
365
"Return None if no position in the string matches.");
366
367
#define _SRE_SRE_PATTERN_SEARCH_METHODDEF    \
368
    {"search", _PyCFunction_CAST(_sre_SRE_Pattern_search), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_search__doc__},
369
370
static PyObject *
371
_sre_SRE_Pattern_search_impl(PatternObject *self, PyTypeObject *cls,
372
                             PyObject *string, Py_ssize_t pos,
373
                             Py_ssize_t endpos);
374
375
static PyObject *
376
_sre_SRE_Pattern_search(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
377
5.33M
{
378
5.33M
    PyObject *return_value = NULL;
379
5.33M
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
380
381
5.33M
    #define NUM_KEYWORDS 3
382
5.33M
    static struct {
383
5.33M
        PyGC_Head _this_is_not_used;
384
5.33M
        PyObject_VAR_HEAD
385
5.33M
        Py_hash_t ob_hash;
386
5.33M
        PyObject *ob_item[NUM_KEYWORDS];
387
5.33M
    } _kwtuple = {
388
5.33M
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
389
5.33M
        .ob_hash = -1,
390
5.33M
        .ob_item = { &_Py_ID(string), &_Py_ID(pos), &_Py_ID(endpos), },
391
5.33M
    };
392
5.33M
    #undef NUM_KEYWORDS
393
5.33M
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
394
395
    #else  // !Py_BUILD_CORE
396
    #  define KWTUPLE NULL
397
    #endif  // !Py_BUILD_CORE
398
399
5.33M
    static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
400
5.33M
    static _PyArg_Parser _parser = {
401
5.33M
        .keywords = _keywords,
402
5.33M
        .fname = "search",
403
5.33M
        .kwtuple = KWTUPLE,
404
5.33M
    };
405
5.33M
    #undef KWTUPLE
406
5.33M
    PyObject *argsbuf[3];
407
5.33M
    Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
408
5.33M
    PyObject *string;
409
5.33M
    Py_ssize_t pos = 0;
410
5.33M
    Py_ssize_t endpos = PY_SSIZE_T_MAX;
411
412
5.33M
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
413
5.33M
            /*minpos*/ 1, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
414
5.33M
    if (!args) {
415
0
        goto exit;
416
0
    }
417
5.33M
    string = args[0];
418
5.33M
    if (!noptargs) {
419
5.33M
        goto skip_optional_pos;
420
5.33M
    }
421
0
    if (args[1]) {
422
0
        {
423
0
            Py_ssize_t ival = -1;
424
0
            PyObject *iobj = _PyNumber_Index(args[1]);
425
0
            if (iobj != NULL) {
426
0
                ival = PyLong_AsSsize_t(iobj);
427
0
                Py_DECREF(iobj);
428
0
            }
429
0
            if (ival == -1 && PyErr_Occurred()) {
430
0
                goto exit;
431
0
            }
432
0
            pos = ival;
433
0
        }
434
0
        if (!--noptargs) {
435
0
            goto skip_optional_pos;
436
0
        }
437
0
    }
438
0
    {
439
0
        Py_ssize_t ival = -1;
440
0
        PyObject *iobj = _PyNumber_Index(args[2]);
441
0
        if (iobj != NULL) {
442
0
            ival = PyLong_AsSsize_t(iobj);
443
0
            Py_DECREF(iobj);
444
0
        }
445
0
        if (ival == -1 && PyErr_Occurred()) {
446
0
            goto exit;
447
0
        }
448
0
        endpos = ival;
449
0
    }
450
5.33M
skip_optional_pos:
451
5.33M
    return_value = _sre_SRE_Pattern_search_impl((PatternObject *)self, cls, string, pos, endpos);
452
453
5.33M
exit:
454
5.33M
    return return_value;
455
5.33M
}
456
457
PyDoc_STRVAR(_sre_SRE_Pattern_findall__doc__,
458
"findall($self, /, string, pos=0, endpos=sys.maxsize)\n"
459
"--\n"
460
"\n"
461
"Return a list of all non-overlapping matches of pattern in string.");
462
463
#define _SRE_SRE_PATTERN_FINDALL_METHODDEF    \
464
    {"findall", _PyCFunction_CAST(_sre_SRE_Pattern_findall), METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_findall__doc__},
465
466
static PyObject *
467
_sre_SRE_Pattern_findall_impl(PatternObject *self, PyObject *string,
468
                              Py_ssize_t pos, Py_ssize_t endpos);
469
470
static PyObject *
471
_sre_SRE_Pattern_findall(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
472
4.04M
{
473
4.04M
    PyObject *return_value = NULL;
474
4.04M
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
475
476
4.04M
    #define NUM_KEYWORDS 3
477
4.04M
    static struct {
478
4.04M
        PyGC_Head _this_is_not_used;
479
4.04M
        PyObject_VAR_HEAD
480
4.04M
        Py_hash_t ob_hash;
481
4.04M
        PyObject *ob_item[NUM_KEYWORDS];
482
4.04M
    } _kwtuple = {
483
4.04M
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
484
4.04M
        .ob_hash = -1,
485
4.04M
        .ob_item = { &_Py_ID(string), &_Py_ID(pos), &_Py_ID(endpos), },
486
4.04M
    };
487
4.04M
    #undef NUM_KEYWORDS
488
4.04M
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
489
490
    #else  // !Py_BUILD_CORE
491
    #  define KWTUPLE NULL
492
    #endif  // !Py_BUILD_CORE
493
494
4.04M
    static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
495
4.04M
    static _PyArg_Parser _parser = {
496
4.04M
        .keywords = _keywords,
497
4.04M
        .fname = "findall",
498
4.04M
        .kwtuple = KWTUPLE,
499
4.04M
    };
500
4.04M
    #undef KWTUPLE
501
4.04M
    PyObject *argsbuf[3];
502
4.04M
    Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
503
4.04M
    PyObject *string;
504
4.04M
    Py_ssize_t pos = 0;
505
4.04M
    Py_ssize_t endpos = PY_SSIZE_T_MAX;
506
507
4.04M
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
508
4.04M
            /*minpos*/ 1, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
509
4.04M
    if (!args) {
510
0
        goto exit;
511
0
    }
512
4.04M
    string = args[0];
513
4.04M
    if (!noptargs) {
514
4.04M
        goto skip_optional_pos;
515
4.04M
    }
516
0
    if (args[1]) {
517
0
        {
518
0
            Py_ssize_t ival = -1;
519
0
            PyObject *iobj = _PyNumber_Index(args[1]);
520
0
            if (iobj != NULL) {
521
0
                ival = PyLong_AsSsize_t(iobj);
522
0
                Py_DECREF(iobj);
523
0
            }
524
0
            if (ival == -1 && PyErr_Occurred()) {
525
0
                goto exit;
526
0
            }
527
0
            pos = ival;
528
0
        }
529
0
        if (!--noptargs) {
530
0
            goto skip_optional_pos;
531
0
        }
532
0
    }
533
0
    {
534
0
        Py_ssize_t ival = -1;
535
0
        PyObject *iobj = _PyNumber_Index(args[2]);
536
0
        if (iobj != NULL) {
537
0
            ival = PyLong_AsSsize_t(iobj);
538
0
            Py_DECREF(iobj);
539
0
        }
540
0
        if (ival == -1 && PyErr_Occurred()) {
541
0
            goto exit;
542
0
        }
543
0
        endpos = ival;
544
0
    }
545
4.04M
skip_optional_pos:
546
4.04M
    return_value = _sre_SRE_Pattern_findall_impl((PatternObject *)self, string, pos, endpos);
547
548
4.04M
exit:
549
4.04M
    return return_value;
550
4.04M
}
551
552
PyDoc_STRVAR(_sre_SRE_Pattern_finditer__doc__,
553
"finditer($self, /, string, pos=0, endpos=sys.maxsize)\n"
554
"--\n"
555
"\n"
556
"Return an iterator over all non-overlapping matches for the RE pattern in string.\n"
557
"\n"
558
"For each match, the iterator returns a match object.");
559
560
#define _SRE_SRE_PATTERN_FINDITER_METHODDEF    \
561
    {"finditer", _PyCFunction_CAST(_sre_SRE_Pattern_finditer), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_finditer__doc__},
562
563
static PyObject *
564
_sre_SRE_Pattern_finditer_impl(PatternObject *self, PyTypeObject *cls,
565
                               PyObject *string, Py_ssize_t pos,
566
                               Py_ssize_t endpos);
567
568
static PyObject *
569
_sre_SRE_Pattern_finditer(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
570
376k
{
571
376k
    PyObject *return_value = NULL;
572
376k
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
573
574
376k
    #define NUM_KEYWORDS 3
575
376k
    static struct {
576
376k
        PyGC_Head _this_is_not_used;
577
376k
        PyObject_VAR_HEAD
578
376k
        Py_hash_t ob_hash;
579
376k
        PyObject *ob_item[NUM_KEYWORDS];
580
376k
    } _kwtuple = {
581
376k
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
582
376k
        .ob_hash = -1,
583
376k
        .ob_item = { &_Py_ID(string), &_Py_ID(pos), &_Py_ID(endpos), },
584
376k
    };
585
376k
    #undef NUM_KEYWORDS
586
376k
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
587
588
    #else  // !Py_BUILD_CORE
589
    #  define KWTUPLE NULL
590
    #endif  // !Py_BUILD_CORE
591
592
376k
    static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
593
376k
    static _PyArg_Parser _parser = {
594
376k
        .keywords = _keywords,
595
376k
        .fname = "finditer",
596
376k
        .kwtuple = KWTUPLE,
597
376k
    };
598
376k
    #undef KWTUPLE
599
376k
    PyObject *argsbuf[3];
600
376k
    Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
601
376k
    PyObject *string;
602
376k
    Py_ssize_t pos = 0;
603
376k
    Py_ssize_t endpos = PY_SSIZE_T_MAX;
604
605
376k
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
606
376k
            /*minpos*/ 1, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
607
376k
    if (!args) {
608
0
        goto exit;
609
0
    }
610
376k
    string = args[0];
611
376k
    if (!noptargs) {
612
376k
        goto skip_optional_pos;
613
376k
    }
614
0
    if (args[1]) {
615
0
        {
616
0
            Py_ssize_t ival = -1;
617
0
            PyObject *iobj = _PyNumber_Index(args[1]);
618
0
            if (iobj != NULL) {
619
0
                ival = PyLong_AsSsize_t(iobj);
620
0
                Py_DECREF(iobj);
621
0
            }
622
0
            if (ival == -1 && PyErr_Occurred()) {
623
0
                goto exit;
624
0
            }
625
0
            pos = ival;
626
0
        }
627
0
        if (!--noptargs) {
628
0
            goto skip_optional_pos;
629
0
        }
630
0
    }
631
0
    {
632
0
        Py_ssize_t ival = -1;
633
0
        PyObject *iobj = _PyNumber_Index(args[2]);
634
0
        if (iobj != NULL) {
635
0
            ival = PyLong_AsSsize_t(iobj);
636
0
            Py_DECREF(iobj);
637
0
        }
638
0
        if (ival == -1 && PyErr_Occurred()) {
639
0
            goto exit;
640
0
        }
641
0
        endpos = ival;
642
0
    }
643
376k
skip_optional_pos:
644
376k
    return_value = _sre_SRE_Pattern_finditer_impl((PatternObject *)self, cls, string, pos, endpos);
645
646
376k
exit:
647
376k
    return return_value;
648
376k
}
649
650
PyDoc_STRVAR(_sre_SRE_Pattern_scanner__doc__,
651
"scanner($self, /, string, pos=0, endpos=sys.maxsize)\n"
652
"--\n"
653
"\n");
654
655
#define _SRE_SRE_PATTERN_SCANNER_METHODDEF    \
656
    {"scanner", _PyCFunction_CAST(_sre_SRE_Pattern_scanner), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_scanner__doc__},
657
658
static PyObject *
659
_sre_SRE_Pattern_scanner_impl(PatternObject *self, PyTypeObject *cls,
660
                              PyObject *string, Py_ssize_t pos,
661
                              Py_ssize_t endpos);
662
663
static PyObject *
664
_sre_SRE_Pattern_scanner(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
665
0
{
666
0
    PyObject *return_value = NULL;
667
0
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
668
669
0
    #define NUM_KEYWORDS 3
670
0
    static struct {
671
0
        PyGC_Head _this_is_not_used;
672
0
        PyObject_VAR_HEAD
673
0
        Py_hash_t ob_hash;
674
0
        PyObject *ob_item[NUM_KEYWORDS];
675
0
    } _kwtuple = {
676
0
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
677
0
        .ob_hash = -1,
678
0
        .ob_item = { &_Py_ID(string), &_Py_ID(pos), &_Py_ID(endpos), },
679
0
    };
680
0
    #undef NUM_KEYWORDS
681
0
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
682
683
    #else  // !Py_BUILD_CORE
684
    #  define KWTUPLE NULL
685
    #endif  // !Py_BUILD_CORE
686
687
0
    static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
688
0
    static _PyArg_Parser _parser = {
689
0
        .keywords = _keywords,
690
0
        .fname = "scanner",
691
0
        .kwtuple = KWTUPLE,
692
0
    };
693
0
    #undef KWTUPLE
694
0
    PyObject *argsbuf[3];
695
0
    Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
696
0
    PyObject *string;
697
0
    Py_ssize_t pos = 0;
698
0
    Py_ssize_t endpos = PY_SSIZE_T_MAX;
699
700
0
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
701
0
            /*minpos*/ 1, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
702
0
    if (!args) {
703
0
        goto exit;
704
0
    }
705
0
    string = args[0];
706
0
    if (!noptargs) {
707
0
        goto skip_optional_pos;
708
0
    }
709
0
    if (args[1]) {
710
0
        {
711
0
            Py_ssize_t ival = -1;
712
0
            PyObject *iobj = _PyNumber_Index(args[1]);
713
0
            if (iobj != NULL) {
714
0
                ival = PyLong_AsSsize_t(iobj);
715
0
                Py_DECREF(iobj);
716
0
            }
717
0
            if (ival == -1 && PyErr_Occurred()) {
718
0
                goto exit;
719
0
            }
720
0
            pos = ival;
721
0
        }
722
0
        if (!--noptargs) {
723
0
            goto skip_optional_pos;
724
0
        }
725
0
    }
726
0
    {
727
0
        Py_ssize_t ival = -1;
728
0
        PyObject *iobj = _PyNumber_Index(args[2]);
729
0
        if (iobj != NULL) {
730
0
            ival = PyLong_AsSsize_t(iobj);
731
0
            Py_DECREF(iobj);
732
0
        }
733
0
        if (ival == -1 && PyErr_Occurred()) {
734
0
            goto exit;
735
0
        }
736
0
        endpos = ival;
737
0
    }
738
0
skip_optional_pos:
739
0
    return_value = _sre_SRE_Pattern_scanner_impl((PatternObject *)self, cls, string, pos, endpos);
740
741
0
exit:
742
0
    return return_value;
743
0
}
744
745
PyDoc_STRVAR(_sre_SRE_Pattern_split__doc__,
746
"split($self, /, string, maxsplit=0)\n"
747
"--\n"
748
"\n"
749
"Split string by the occurrences of pattern.");
750
751
#define _SRE_SRE_PATTERN_SPLIT_METHODDEF    \
752
    {"split", _PyCFunction_CAST(_sre_SRE_Pattern_split), METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_split__doc__},
753
754
static PyObject *
755
_sre_SRE_Pattern_split_impl(PatternObject *self, PyObject *string,
756
                            Py_ssize_t maxsplit);
757
758
static PyObject *
759
_sre_SRE_Pattern_split(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
760
1.41M
{
761
1.41M
    PyObject *return_value = NULL;
762
1.41M
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
763
764
1.41M
    #define NUM_KEYWORDS 2
765
1.41M
    static struct {
766
1.41M
        PyGC_Head _this_is_not_used;
767
1.41M
        PyObject_VAR_HEAD
768
1.41M
        Py_hash_t ob_hash;
769
1.41M
        PyObject *ob_item[NUM_KEYWORDS];
770
1.41M
    } _kwtuple = {
771
1.41M
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
772
1.41M
        .ob_hash = -1,
773
1.41M
        .ob_item = { &_Py_ID(string), &_Py_ID(maxsplit), },
774
1.41M
    };
775
1.41M
    #undef NUM_KEYWORDS
776
1.41M
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
777
778
    #else  // !Py_BUILD_CORE
779
    #  define KWTUPLE NULL
780
    #endif  // !Py_BUILD_CORE
781
782
1.41M
    static const char * const _keywords[] = {"string", "maxsplit", NULL};
783
1.41M
    static _PyArg_Parser _parser = {
784
1.41M
        .keywords = _keywords,
785
1.41M
        .fname = "split",
786
1.41M
        .kwtuple = KWTUPLE,
787
1.41M
    };
788
1.41M
    #undef KWTUPLE
789
1.41M
    PyObject *argsbuf[2];
790
1.41M
    Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
791
1.41M
    PyObject *string;
792
1.41M
    Py_ssize_t maxsplit = 0;
793
794
1.41M
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
795
1.41M
            /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
796
1.41M
    if (!args) {
797
0
        goto exit;
798
0
    }
799
1.41M
    string = args[0];
800
1.41M
    if (!noptargs) {
801
251k
        goto skip_optional_pos;
802
251k
    }
803
1.16M
    {
804
1.16M
        Py_ssize_t ival = -1;
805
1.16M
        PyObject *iobj = _PyNumber_Index(args[1]);
806
1.16M
        if (iobj != NULL) {
807
1.16M
            ival = PyLong_AsSsize_t(iobj);
808
1.16M
            Py_DECREF(iobj);
809
1.16M
        }
810
1.16M
        if (ival == -1 && PyErr_Occurred()) {
811
0
            goto exit;
812
0
        }
813
1.16M
        maxsplit = ival;
814
1.16M
    }
815
1.41M
skip_optional_pos:
816
1.41M
    return_value = _sre_SRE_Pattern_split_impl((PatternObject *)self, string, maxsplit);
817
818
1.41M
exit:
819
1.41M
    return return_value;
820
1.41M
}
821
822
PyDoc_STRVAR(_sre_SRE_Pattern_sub__doc__,
823
"sub($self, /, repl, string, count=0)\n"
824
"--\n"
825
"\n"
826
"Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl.");
827
828
#define _SRE_SRE_PATTERN_SUB_METHODDEF    \
829
    {"sub", _PyCFunction_CAST(_sre_SRE_Pattern_sub), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_sub__doc__},
830
831
static PyObject *
832
_sre_SRE_Pattern_sub_impl(PatternObject *self, PyTypeObject *cls,
833
                          PyObject *repl, PyObject *string, Py_ssize_t count);
834
835
static PyObject *
836
_sre_SRE_Pattern_sub(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
837
7.56M
{
838
7.56M
    PyObject *return_value = NULL;
839
7.56M
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
840
841
7.56M
    #define NUM_KEYWORDS 3
842
7.56M
    static struct {
843
7.56M
        PyGC_Head _this_is_not_used;
844
7.56M
        PyObject_VAR_HEAD
845
7.56M
        Py_hash_t ob_hash;
846
7.56M
        PyObject *ob_item[NUM_KEYWORDS];
847
7.56M
    } _kwtuple = {
848
7.56M
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
849
7.56M
        .ob_hash = -1,
850
7.56M
        .ob_item = { &_Py_ID(repl), &_Py_ID(string), &_Py_ID(count), },
851
7.56M
    };
852
7.56M
    #undef NUM_KEYWORDS
853
7.56M
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
854
855
    #else  // !Py_BUILD_CORE
856
    #  define KWTUPLE NULL
857
    #endif  // !Py_BUILD_CORE
858
859
7.56M
    static const char * const _keywords[] = {"repl", "string", "count", NULL};
860
7.56M
    static _PyArg_Parser _parser = {
861
7.56M
        .keywords = _keywords,
862
7.56M
        .fname = "sub",
863
7.56M
        .kwtuple = KWTUPLE,
864
7.56M
    };
865
7.56M
    #undef KWTUPLE
866
7.56M
    PyObject *argsbuf[3];
867
7.56M
    Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
868
7.56M
    PyObject *repl;
869
7.56M
    PyObject *string;
870
7.56M
    Py_ssize_t count = 0;
871
872
7.56M
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
873
7.56M
            /*minpos*/ 2, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
874
7.56M
    if (!args) {
875
0
        goto exit;
876
0
    }
877
7.56M
    repl = args[0];
878
7.56M
    string = args[1];
879
7.56M
    if (!noptargs) {
880
7.56M
        goto skip_optional_pos;
881
7.56M
    }
882
0
    {
883
0
        Py_ssize_t ival = -1;
884
0
        PyObject *iobj = _PyNumber_Index(args[2]);
885
0
        if (iobj != NULL) {
886
0
            ival = PyLong_AsSsize_t(iobj);
887
0
            Py_DECREF(iobj);
888
0
        }
889
0
        if (ival == -1 && PyErr_Occurred()) {
890
0
            goto exit;
891
0
        }
892
0
        count = ival;
893
0
    }
894
7.56M
skip_optional_pos:
895
7.56M
    return_value = _sre_SRE_Pattern_sub_impl((PatternObject *)self, cls, repl, string, count);
896
897
7.56M
exit:
898
7.56M
    return return_value;
899
7.56M
}
900
901
PyDoc_STRVAR(_sre_SRE_Pattern_subn__doc__,
902
"subn($self, /, repl, string, count=0)\n"
903
"--\n"
904
"\n"
905
"Return the tuple (new_string, number_of_subs_made) found by replacing the leftmost non-overlapping occurrences of pattern with the replacement repl.");
906
907
#define _SRE_SRE_PATTERN_SUBN_METHODDEF    \
908
    {"subn", _PyCFunction_CAST(_sre_SRE_Pattern_subn), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_subn__doc__},
909
910
static PyObject *
911
_sre_SRE_Pattern_subn_impl(PatternObject *self, PyTypeObject *cls,
912
                           PyObject *repl, PyObject *string,
913
                           Py_ssize_t count);
914
915
static PyObject *
916
_sre_SRE_Pattern_subn(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
917
0
{
918
0
    PyObject *return_value = NULL;
919
0
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
920
921
0
    #define NUM_KEYWORDS 3
922
0
    static struct {
923
0
        PyGC_Head _this_is_not_used;
924
0
        PyObject_VAR_HEAD
925
0
        Py_hash_t ob_hash;
926
0
        PyObject *ob_item[NUM_KEYWORDS];
927
0
    } _kwtuple = {
928
0
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
929
0
        .ob_hash = -1,
930
0
        .ob_item = { &_Py_ID(repl), &_Py_ID(string), &_Py_ID(count), },
931
0
    };
932
0
    #undef NUM_KEYWORDS
933
0
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
934
935
    #else  // !Py_BUILD_CORE
936
    #  define KWTUPLE NULL
937
    #endif  // !Py_BUILD_CORE
938
939
0
    static const char * const _keywords[] = {"repl", "string", "count", NULL};
940
0
    static _PyArg_Parser _parser = {
941
0
        .keywords = _keywords,
942
0
        .fname = "subn",
943
0
        .kwtuple = KWTUPLE,
944
0
    };
945
0
    #undef KWTUPLE
946
0
    PyObject *argsbuf[3];
947
0
    Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
948
0
    PyObject *repl;
949
0
    PyObject *string;
950
0
    Py_ssize_t count = 0;
951
952
0
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
953
0
            /*minpos*/ 2, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
954
0
    if (!args) {
955
0
        goto exit;
956
0
    }
957
0
    repl = args[0];
958
0
    string = args[1];
959
0
    if (!noptargs) {
960
0
        goto skip_optional_pos;
961
0
    }
962
0
    {
963
0
        Py_ssize_t ival = -1;
964
0
        PyObject *iobj = _PyNumber_Index(args[2]);
965
0
        if (iobj != NULL) {
966
0
            ival = PyLong_AsSsize_t(iobj);
967
0
            Py_DECREF(iobj);
968
0
        }
969
0
        if (ival == -1 && PyErr_Occurred()) {
970
0
            goto exit;
971
0
        }
972
0
        count = ival;
973
0
    }
974
0
skip_optional_pos:
975
0
    return_value = _sre_SRE_Pattern_subn_impl((PatternObject *)self, cls, repl, string, count);
976
977
0
exit:
978
0
    return return_value;
979
0
}
980
981
PyDoc_STRVAR(_sre_SRE_Pattern___copy____doc__,
982
"__copy__($self, /)\n"
983
"--\n"
984
"\n");
985
986
#define _SRE_SRE_PATTERN___COPY___METHODDEF    \
987
    {"__copy__", (PyCFunction)_sre_SRE_Pattern___copy__, METH_NOARGS, _sre_SRE_Pattern___copy____doc__},
988
989
static PyObject *
990
_sre_SRE_Pattern___copy___impl(PatternObject *self);
991
992
static PyObject *
993
_sre_SRE_Pattern___copy__(PyObject *self, PyObject *Py_UNUSED(ignored))
994
0
{
995
0
    return _sre_SRE_Pattern___copy___impl((PatternObject *)self);
996
0
}
997
998
PyDoc_STRVAR(_sre_SRE_Pattern___deepcopy____doc__,
999
"__deepcopy__($self, memo, /)\n"
1000
"--\n"
1001
"\n");
1002
1003
#define _SRE_SRE_PATTERN___DEEPCOPY___METHODDEF    \
1004
    {"__deepcopy__", (PyCFunction)_sre_SRE_Pattern___deepcopy__, METH_O, _sre_SRE_Pattern___deepcopy____doc__},
1005
1006
static PyObject *
1007
_sre_SRE_Pattern___deepcopy___impl(PatternObject *self, PyObject *memo);
1008
1009
static PyObject *
1010
_sre_SRE_Pattern___deepcopy__(PyObject *self, PyObject *memo)
1011
0
{
1012
0
    PyObject *return_value = NULL;
1013
1014
0
    return_value = _sre_SRE_Pattern___deepcopy___impl((PatternObject *)self, memo);
1015
1016
0
    return return_value;
1017
0
}
1018
1019
#if defined(Py_DEBUG)
1020
1021
PyDoc_STRVAR(_sre_SRE_Pattern__fail_after__doc__,
1022
"_fail_after($self, count, exception, /)\n"
1023
"--\n"
1024
"\n"
1025
"For debugging.");
1026
1027
#define _SRE_SRE_PATTERN__FAIL_AFTER_METHODDEF    \
1028
    {"_fail_after", _PyCFunction_CAST(_sre_SRE_Pattern__fail_after), METH_FASTCALL, _sre_SRE_Pattern__fail_after__doc__},
1029
1030
static PyObject *
1031
_sre_SRE_Pattern__fail_after_impl(PatternObject *self, int count,
1032
                                  PyObject *exception);
1033
1034
static PyObject *
1035
_sre_SRE_Pattern__fail_after(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
1036
{
1037
    PyObject *return_value = NULL;
1038
    int count;
1039
    PyObject *exception;
1040
1041
    if (!_PyArg_CheckPositional("_fail_after", nargs, 2, 2)) {
1042
        goto exit;
1043
    }
1044
    count = PyLong_AsInt(args[0]);
1045
    if (count == -1 && PyErr_Occurred()) {
1046
        goto exit;
1047
    }
1048
    exception = args[1];
1049
    return_value = _sre_SRE_Pattern__fail_after_impl((PatternObject *)self, count, exception);
1050
1051
exit:
1052
    return return_value;
1053
}
1054
1055
#endif /* defined(Py_DEBUG) */
1056
1057
PyDoc_STRVAR(_sre_compile__doc__,
1058
"compile($module, /, pattern, flags, code, groups, groupindex,\n"
1059
"        indexgroup)\n"
1060
"--\n"
1061
"\n");
1062
1063
#define _SRE_COMPILE_METHODDEF    \
1064
    {"compile", _PyCFunction_CAST(_sre_compile), METH_FASTCALL|METH_KEYWORDS, _sre_compile__doc__},
1065
1066
static PyObject *
1067
_sre_compile_impl(PyObject *module, PyObject *pattern, int flags,
1068
                  PyObject *code, Py_ssize_t groups, PyObject *groupindex,
1069
                  PyObject *indexgroup);
1070
1071
static PyObject *
1072
_sre_compile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1073
3.10k
{
1074
3.10k
    PyObject *return_value = NULL;
1075
3.10k
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1076
1077
3.10k
    #define NUM_KEYWORDS 6
1078
3.10k
    static struct {
1079
3.10k
        PyGC_Head _this_is_not_used;
1080
3.10k
        PyObject_VAR_HEAD
1081
3.10k
        Py_hash_t ob_hash;
1082
3.10k
        PyObject *ob_item[NUM_KEYWORDS];
1083
3.10k
    } _kwtuple = {
1084
3.10k
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1085
3.10k
        .ob_hash = -1,
1086
3.10k
        .ob_item = { &_Py_ID(pattern), &_Py_ID(flags), &_Py_ID(code), &_Py_ID(groups), &_Py_ID(groupindex), &_Py_ID(indexgroup), },
1087
3.10k
    };
1088
3.10k
    #undef NUM_KEYWORDS
1089
3.10k
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1090
1091
    #else  // !Py_BUILD_CORE
1092
    #  define KWTUPLE NULL
1093
    #endif  // !Py_BUILD_CORE
1094
1095
3.10k
    static const char * const _keywords[] = {"pattern", "flags", "code", "groups", "groupindex", "indexgroup", NULL};
1096
3.10k
    static _PyArg_Parser _parser = {
1097
3.10k
        .keywords = _keywords,
1098
3.10k
        .fname = "compile",
1099
3.10k
        .kwtuple = KWTUPLE,
1100
3.10k
    };
1101
3.10k
    #undef KWTUPLE
1102
3.10k
    PyObject *argsbuf[6];
1103
3.10k
    PyObject *pattern;
1104
3.10k
    int flags;
1105
3.10k
    PyObject *code;
1106
3.10k
    Py_ssize_t groups;
1107
3.10k
    PyObject *groupindex;
1108
3.10k
    PyObject *indexgroup;
1109
1110
3.10k
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1111
3.10k
            /*minpos*/ 6, /*maxpos*/ 6, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1112
3.10k
    if (!args) {
1113
0
        goto exit;
1114
0
    }
1115
3.10k
    pattern = args[0];
1116
3.10k
    flags = PyLong_AsInt(args[1]);
1117
3.10k
    if (flags == -1 && PyErr_Occurred()) {
1118
0
        goto exit;
1119
0
    }
1120
3.10k
    if (!PyList_Check(args[2])) {
1121
0
        _PyArg_BadArgument("compile", "argument 'code'", "list", args[2]);
1122
0
        goto exit;
1123
0
    }
1124
3.10k
    code = args[2];
1125
3.10k
    {
1126
3.10k
        Py_ssize_t ival = -1;
1127
3.10k
        PyObject *iobj = _PyNumber_Index(args[3]);
1128
3.10k
        if (iobj != NULL) {
1129
3.10k
            ival = PyLong_AsSsize_t(iobj);
1130
3.10k
            Py_DECREF(iobj);
1131
3.10k
        }
1132
3.10k
        if (ival == -1 && PyErr_Occurred()) {
1133
0
            goto exit;
1134
0
        }
1135
3.10k
        groups = ival;
1136
3.10k
    }
1137
3.10k
    if (!PyDict_Check(args[4])) {
1138
0
        _PyArg_BadArgument("compile", "argument 'groupindex'", "dict", args[4]);
1139
0
        goto exit;
1140
0
    }
1141
3.10k
    groupindex = args[4];
1142
3.10k
    if (!PyTuple_Check(args[5])) {
1143
0
        _PyArg_BadArgument("compile", "argument 'indexgroup'", "tuple", args[5]);
1144
0
        goto exit;
1145
0
    }
1146
3.10k
    indexgroup = args[5];
1147
3.10k
    return_value = _sre_compile_impl(module, pattern, flags, code, groups, groupindex, indexgroup);
1148
1149
3.10k
exit:
1150
3.10k
    return return_value;
1151
3.10k
}
1152
1153
PyDoc_STRVAR(_sre_template__doc__,
1154
"template($module, pattern, template, /)\n"
1155
"--\n"
1156
"\n"
1157
"\n"
1158
"\n"
1159
"  template\n"
1160
"    A list containing interleaved literal strings (str or bytes) and group\n"
1161
"    indices (int), as returned by re._parser.parse_template():\n"
1162
"        [literal1, group1, ..., literalN, groupN]");
1163
1164
#define _SRE_TEMPLATE_METHODDEF    \
1165
    {"template", _PyCFunction_CAST(_sre_template), METH_FASTCALL, _sre_template__doc__},
1166
1167
static PyObject *
1168
_sre_template_impl(PyObject *module, PyObject *pattern, PyObject *template);
1169
1170
static PyObject *
1171
_sre_template(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1172
0
{
1173
0
    PyObject *return_value = NULL;
1174
0
    PyObject *pattern;
1175
0
    PyObject *template;
1176
1177
0
    if (!_PyArg_CheckPositional("template", nargs, 2, 2)) {
1178
0
        goto exit;
1179
0
    }
1180
0
    pattern = args[0];
1181
0
    if (!PyList_Check(args[1])) {
1182
0
        _PyArg_BadArgument("template", "argument 2", "list", args[1]);
1183
0
        goto exit;
1184
0
    }
1185
0
    template = args[1];
1186
0
    return_value = _sre_template_impl(module, pattern, template);
1187
1188
0
exit:
1189
0
    return return_value;
1190
0
}
1191
1192
PyDoc_STRVAR(_sre_SRE_Match_expand__doc__,
1193
"expand($self, /, template)\n"
1194
"--\n"
1195
"\n"
1196
"Return the string obtained by doing backslash substitution on the string template, as done by the sub() method.");
1197
1198
#define _SRE_SRE_MATCH_EXPAND_METHODDEF    \
1199
    {"expand", _PyCFunction_CAST(_sre_SRE_Match_expand), METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Match_expand__doc__},
1200
1201
static PyObject *
1202
_sre_SRE_Match_expand_impl(MatchObject *self, PyObject *template);
1203
1204
static PyObject *
1205
_sre_SRE_Match_expand(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1206
0
{
1207
0
    PyObject *return_value = NULL;
1208
0
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1209
1210
0
    #define NUM_KEYWORDS 1
1211
0
    static struct {
1212
0
        PyGC_Head _this_is_not_used;
1213
0
        PyObject_VAR_HEAD
1214
0
        Py_hash_t ob_hash;
1215
0
        PyObject *ob_item[NUM_KEYWORDS];
1216
0
    } _kwtuple = {
1217
0
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1218
0
        .ob_hash = -1,
1219
0
        .ob_item = { &_Py_ID(template), },
1220
0
    };
1221
0
    #undef NUM_KEYWORDS
1222
0
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1223
1224
    #else  // !Py_BUILD_CORE
1225
    #  define KWTUPLE NULL
1226
    #endif  // !Py_BUILD_CORE
1227
1228
0
    static const char * const _keywords[] = {"template", NULL};
1229
0
    static _PyArg_Parser _parser = {
1230
0
        .keywords = _keywords,
1231
0
        .fname = "expand",
1232
0
        .kwtuple = KWTUPLE,
1233
0
    };
1234
0
    #undef KWTUPLE
1235
0
    PyObject *argsbuf[1];
1236
0
    PyObject *template;
1237
1238
0
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1239
0
            /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1240
0
    if (!args) {
1241
0
        goto exit;
1242
0
    }
1243
0
    template = args[0];
1244
0
    return_value = _sre_SRE_Match_expand_impl((MatchObject *)self, template);
1245
1246
0
exit:
1247
0
    return return_value;
1248
0
}
1249
1250
PyDoc_STRVAR(_sre_SRE_Match_group__doc__,
1251
"group($self, /, *args)\n"
1252
"--\n"
1253
"\n"
1254
"Return subgroup(s) of the match by indices or names.\n"
1255
"\n"
1256
"For 0 returns the entire match.");
1257
1258
#define _SRE_SRE_MATCH_GROUP_METHODDEF    \
1259
    {"group", _PyCFunction_CAST(_sre_SRE_Match_group), METH_FASTCALL, _sre_SRE_Match_group__doc__},
1260
1261
static PyObject *
1262
_sre_SRE_Match_group_impl(MatchObject *self, PyObject * const *args,
1263
                          Py_ssize_t args_length);
1264
1265
static PyObject *
1266
_sre_SRE_Match_group(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
1267
13.9M
{
1268
13.9M
    PyObject *return_value = NULL;
1269
13.9M
    PyObject * const *__clinic_args;
1270
13.9M
    Py_ssize_t args_length;
1271
1272
13.9M
    __clinic_args = args;
1273
13.9M
    args_length = nargs;
1274
13.9M
    return_value = _sre_SRE_Match_group_impl((MatchObject *)self, __clinic_args, args_length);
1275
1276
13.9M
    return return_value;
1277
13.9M
}
1278
1279
PyDoc_STRVAR(_sre_SRE_Match_groups__doc__,
1280
"groups($self, /, default=None)\n"
1281
"--\n"
1282
"\n"
1283
"Return a tuple containing all the subgroups of the match, from 1.\n"
1284
"\n"
1285
"  default\n"
1286
"    Is used for groups that did not participate in the match.");
1287
1288
#define _SRE_SRE_MATCH_GROUPS_METHODDEF    \
1289
    {"groups", _PyCFunction_CAST(_sre_SRE_Match_groups), METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Match_groups__doc__},
1290
1291
static PyObject *
1292
_sre_SRE_Match_groups_impl(MatchObject *self, PyObject *default_value);
1293
1294
static PyObject *
1295
_sre_SRE_Match_groups(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1296
18.9k
{
1297
18.9k
    PyObject *return_value = NULL;
1298
18.9k
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1299
1300
18.9k
    #define NUM_KEYWORDS 1
1301
18.9k
    static struct {
1302
18.9k
        PyGC_Head _this_is_not_used;
1303
18.9k
        PyObject_VAR_HEAD
1304
18.9k
        Py_hash_t ob_hash;
1305
18.9k
        PyObject *ob_item[NUM_KEYWORDS];
1306
18.9k
    } _kwtuple = {
1307
18.9k
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1308
18.9k
        .ob_hash = -1,
1309
18.9k
        .ob_item = { &_Py_ID(default), },
1310
18.9k
    };
1311
18.9k
    #undef NUM_KEYWORDS
1312
18.9k
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1313
1314
    #else  // !Py_BUILD_CORE
1315
    #  define KWTUPLE NULL
1316
    #endif  // !Py_BUILD_CORE
1317
1318
18.9k
    static const char * const _keywords[] = {"default", NULL};
1319
18.9k
    static _PyArg_Parser _parser = {
1320
18.9k
        .keywords = _keywords,
1321
18.9k
        .fname = "groups",
1322
18.9k
        .kwtuple = KWTUPLE,
1323
18.9k
    };
1324
18.9k
    #undef KWTUPLE
1325
18.9k
    PyObject *argsbuf[1];
1326
18.9k
    Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
1327
18.9k
    PyObject *default_value = Py_None;
1328
1329
18.9k
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1330
18.9k
            /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1331
18.9k
    if (!args) {
1332
0
        goto exit;
1333
0
    }
1334
18.9k
    if (!noptargs) {
1335
18.9k
        goto skip_optional_pos;
1336
18.9k
    }
1337
0
    default_value = args[0];
1338
18.9k
skip_optional_pos:
1339
18.9k
    return_value = _sre_SRE_Match_groups_impl((MatchObject *)self, default_value);
1340
1341
18.9k
exit:
1342
18.9k
    return return_value;
1343
18.9k
}
1344
1345
PyDoc_STRVAR(_sre_SRE_Match_groupdict__doc__,
1346
"groupdict($self, /, default=None)\n"
1347
"--\n"
1348
"\n"
1349
"Return a dictionary containing all the named subgroups of the match, keyed by the subgroup name.\n"
1350
"\n"
1351
"  default\n"
1352
"    Is used for groups that did not participate in the match.");
1353
1354
#define _SRE_SRE_MATCH_GROUPDICT_METHODDEF    \
1355
    {"groupdict", _PyCFunction_CAST(_sre_SRE_Match_groupdict), METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Match_groupdict__doc__},
1356
1357
static PyObject *
1358
_sre_SRE_Match_groupdict_impl(MatchObject *self, PyObject *default_value);
1359
1360
static PyObject *
1361
_sre_SRE_Match_groupdict(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1362
133
{
1363
133
    PyObject *return_value = NULL;
1364
133
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1365
1366
133
    #define NUM_KEYWORDS 1
1367
133
    static struct {
1368
133
        PyGC_Head _this_is_not_used;
1369
133
        PyObject_VAR_HEAD
1370
133
        Py_hash_t ob_hash;
1371
133
        PyObject *ob_item[NUM_KEYWORDS];
1372
133
    } _kwtuple = {
1373
133
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1374
133
        .ob_hash = -1,
1375
133
        .ob_item = { &_Py_ID(default), },
1376
133
    };
1377
133
    #undef NUM_KEYWORDS
1378
133
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1379
1380
    #else  // !Py_BUILD_CORE
1381
    #  define KWTUPLE NULL
1382
    #endif  // !Py_BUILD_CORE
1383
1384
133
    static const char * const _keywords[] = {"default", NULL};
1385
133
    static _PyArg_Parser _parser = {
1386
133
        .keywords = _keywords,
1387
133
        .fname = "groupdict",
1388
133
        .kwtuple = KWTUPLE,
1389
133
    };
1390
133
    #undef KWTUPLE
1391
133
    PyObject *argsbuf[1];
1392
133
    Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
1393
133
    PyObject *default_value = Py_None;
1394
1395
133
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1396
133
            /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1397
133
    if (!args) {
1398
0
        goto exit;
1399
0
    }
1400
133
    if (!noptargs) {
1401
133
        goto skip_optional_pos;
1402
133
    }
1403
0
    default_value = args[0];
1404
133
skip_optional_pos:
1405
133
    return_value = _sre_SRE_Match_groupdict_impl((MatchObject *)self, default_value);
1406
1407
133
exit:
1408
133
    return return_value;
1409
133
}
1410
1411
PyDoc_STRVAR(_sre_SRE_Match_start__doc__,
1412
"start($self, group=0, /)\n"
1413
"--\n"
1414
"\n"
1415
"Return index of the start of the substring matched by group.");
1416
1417
#define _SRE_SRE_MATCH_START_METHODDEF    \
1418
    {"start", _PyCFunction_CAST(_sre_SRE_Match_start), METH_FASTCALL, _sre_SRE_Match_start__doc__},
1419
1420
static Py_ssize_t
1421
_sre_SRE_Match_start_impl(MatchObject *self, PyObject *group);
1422
1423
static PyObject *
1424
_sre_SRE_Match_start(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
1425
5.62M
{
1426
5.62M
    PyObject *return_value = NULL;
1427
5.62M
    PyObject *group = NULL;
1428
5.62M
    Py_ssize_t _return_value;
1429
1430
5.62M
    if (!_PyArg_CheckPositional("start", nargs, 0, 1)) {
1431
0
        goto exit;
1432
0
    }
1433
5.62M
    if (nargs < 1) {
1434
5.32M
        goto skip_optional;
1435
5.32M
    }
1436
290k
    group = args[0];
1437
5.62M
skip_optional:
1438
5.62M
    _return_value = _sre_SRE_Match_start_impl((MatchObject *)self, group);
1439
5.62M
    if ((_return_value == -1) && PyErr_Occurred()) {
1440
0
        goto exit;
1441
0
    }
1442
5.62M
    return_value = PyLong_FromSsize_t(_return_value);
1443
1444
5.62M
exit:
1445
5.62M
    return return_value;
1446
5.62M
}
1447
1448
PyDoc_STRVAR(_sre_SRE_Match_end__doc__,
1449
"end($self, group=0, /)\n"
1450
"--\n"
1451
"\n"
1452
"Return index of the end of the substring matched by group.");
1453
1454
#define _SRE_SRE_MATCH_END_METHODDEF    \
1455
    {"end", _PyCFunction_CAST(_sre_SRE_Match_end), METH_FASTCALL, _sre_SRE_Match_end__doc__},
1456
1457
static Py_ssize_t
1458
_sre_SRE_Match_end_impl(MatchObject *self, PyObject *group);
1459
1460
static PyObject *
1461
_sre_SRE_Match_end(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
1462
1.42M
{
1463
1.42M
    PyObject *return_value = NULL;
1464
1.42M
    PyObject *group = NULL;
1465
1.42M
    Py_ssize_t _return_value;
1466
1467
1.42M
    if (!_PyArg_CheckPositional("end", nargs, 0, 1)) {
1468
0
        goto exit;
1469
0
    }
1470
1.42M
    if (nargs < 1) {
1471
1.13M
        goto skip_optional;
1472
1.13M
    }
1473
290k
    group = args[0];
1474
1.42M
skip_optional:
1475
1.42M
    _return_value = _sre_SRE_Match_end_impl((MatchObject *)self, group);
1476
1.42M
    if ((_return_value == -1) && PyErr_Occurred()) {
1477
0
        goto exit;
1478
0
    }
1479
1.42M
    return_value = PyLong_FromSsize_t(_return_value);
1480
1481
1.42M
exit:
1482
1.42M
    return return_value;
1483
1.42M
}
1484
1485
PyDoc_STRVAR(_sre_SRE_Match_span__doc__,
1486
"span($self, group=0, /)\n"
1487
"--\n"
1488
"\n"
1489
"For match object m, return the 2-tuple (m.start(group), m.end(group)).");
1490
1491
#define _SRE_SRE_MATCH_SPAN_METHODDEF    \
1492
    {"span", _PyCFunction_CAST(_sre_SRE_Match_span), METH_FASTCALL, _sre_SRE_Match_span__doc__},
1493
1494
static PyObject *
1495
_sre_SRE_Match_span_impl(MatchObject *self, PyObject *group);
1496
1497
static PyObject *
1498
_sre_SRE_Match_span(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
1499
3.45M
{
1500
3.45M
    PyObject *return_value = NULL;
1501
3.45M
    PyObject *group = NULL;
1502
1503
3.45M
    if (!_PyArg_CheckPositional("span", nargs, 0, 1)) {
1504
0
        goto exit;
1505
0
    }
1506
3.45M
    if (nargs < 1) {
1507
3.45M
        goto skip_optional;
1508
3.45M
    }
1509
0
    group = args[0];
1510
3.45M
skip_optional:
1511
3.45M
    return_value = _sre_SRE_Match_span_impl((MatchObject *)self, group);
1512
1513
3.45M
exit:
1514
3.45M
    return return_value;
1515
3.45M
}
1516
1517
PyDoc_STRVAR(_sre_SRE_Match___copy____doc__,
1518
"__copy__($self, /)\n"
1519
"--\n"
1520
"\n");
1521
1522
#define _SRE_SRE_MATCH___COPY___METHODDEF    \
1523
    {"__copy__", (PyCFunction)_sre_SRE_Match___copy__, METH_NOARGS, _sre_SRE_Match___copy____doc__},
1524
1525
static PyObject *
1526
_sre_SRE_Match___copy___impl(MatchObject *self);
1527
1528
static PyObject *
1529
_sre_SRE_Match___copy__(PyObject *self, PyObject *Py_UNUSED(ignored))
1530
0
{
1531
0
    return _sre_SRE_Match___copy___impl((MatchObject *)self);
1532
0
}
1533
1534
PyDoc_STRVAR(_sre_SRE_Match___deepcopy____doc__,
1535
"__deepcopy__($self, memo, /)\n"
1536
"--\n"
1537
"\n");
1538
1539
#define _SRE_SRE_MATCH___DEEPCOPY___METHODDEF    \
1540
    {"__deepcopy__", (PyCFunction)_sre_SRE_Match___deepcopy__, METH_O, _sre_SRE_Match___deepcopy____doc__},
1541
1542
static PyObject *
1543
_sre_SRE_Match___deepcopy___impl(MatchObject *self, PyObject *memo);
1544
1545
static PyObject *
1546
_sre_SRE_Match___deepcopy__(PyObject *self, PyObject *memo)
1547
0
{
1548
0
    PyObject *return_value = NULL;
1549
1550
0
    return_value = _sre_SRE_Match___deepcopy___impl((MatchObject *)self, memo);
1551
1552
0
    return return_value;
1553
0
}
1554
1555
PyDoc_STRVAR(_sre_SRE_Scanner_prefixmatch__doc__,
1556
"prefixmatch($self, /)\n"
1557
"--\n"
1558
"\n");
1559
1560
#define _SRE_SRE_SCANNER_PREFIXMATCH_METHODDEF    \
1561
    {"prefixmatch", _PyCFunction_CAST(_sre_SRE_Scanner_prefixmatch), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Scanner_prefixmatch__doc__},
1562
1563
static PyObject *
1564
_sre_SRE_Scanner_prefixmatch_impl(ScannerObject *self, PyTypeObject *cls);
1565
1566
static PyObject *
1567
_sre_SRE_Scanner_prefixmatch(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1568
0
{
1569
0
    if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) {
1570
0
        PyErr_SetString(PyExc_TypeError, "prefixmatch() takes no arguments");
1571
0
        return NULL;
1572
0
    }
1573
0
    return _sre_SRE_Scanner_prefixmatch_impl((ScannerObject *)self, cls);
1574
0
}
1575
1576
PyDoc_STRVAR(_sre_SRE_Scanner_search__doc__,
1577
"search($self, /)\n"
1578
"--\n"
1579
"\n");
1580
1581
#define _SRE_SRE_SCANNER_SEARCH_METHODDEF    \
1582
    {"search", _PyCFunction_CAST(_sre_SRE_Scanner_search), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Scanner_search__doc__},
1583
1584
static PyObject *
1585
_sre_SRE_Scanner_search_impl(ScannerObject *self, PyTypeObject *cls);
1586
1587
static PyObject *
1588
_sre_SRE_Scanner_search(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1589
3.81M
{
1590
3.81M
    if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) {
1591
0
        PyErr_SetString(PyExc_TypeError, "search() takes no arguments");
1592
0
        return NULL;
1593
0
    }
1594
3.81M
    return _sre_SRE_Scanner_search_impl((ScannerObject *)self, cls);
1595
3.81M
}
1596
1597
#ifndef _SRE_SRE_PATTERN__FAIL_AFTER_METHODDEF
1598
    #define _SRE_SRE_PATTERN__FAIL_AFTER_METHODDEF
1599
#endif /* !defined(_SRE_SRE_PATTERN__FAIL_AFTER_METHODDEF) */
1600
/*[clinic end generated code: output=2e6c222a2eb0875e input=a9049054013a1b77]*/