| 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 |
{ |
| 26 |
PyObject *return_value = NULL; |
| 27 |
int _return_value; |
| 28 |
|
| 29 |
_return_value = _sre_getcodesize_impl(module); |
| 30 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 31 |
goto exit; |
| 32 |
} |
| 33 |
return_value = PyLong_FromLong((long)_return_value); |
| 34 |
|
| 35 |
exit: |
| 36 |
return return_value; |
| 37 |
} |
| 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 |
{ |
| 53 |
PyObject *return_value = NULL; |
| 54 |
int character; |
| 55 |
int _return_value; |
| 56 |
|
| 57 |
character = PyLong_AsInt(arg); |
| 58 |
if (character == -1 && PyErr_Occurred()) { |
| 59 |
goto exit; |
| 60 |
} |
| 61 |
_return_value = _sre_ascii_iscased_impl(module, character); |
| 62 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 63 |
goto exit; |
| 64 |
} |
| 65 |
return_value = PyBool_FromLong((long)_return_value); |
| 66 |
|
| 67 |
exit: |
| 68 |
return return_value; |
| 69 |
} |
| 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 |
{ |
| 85 |
PyObject *return_value = NULL; |
| 86 |
int character; |
| 87 |
int _return_value; |
| 88 |
|
| 89 |
character = PyLong_AsInt(arg); |
| 90 |
if (character == -1 && PyErr_Occurred()) { |
| 91 |
goto exit; |
| 92 |
} |
| 93 |
_return_value = _sre_unicode_iscased_impl(module, character); |
| 94 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 95 |
goto exit; |
| 96 |
} |
| 97 |
return_value = PyBool_FromLong((long)_return_value); |
| 98 |
|
| 99 |
exit: |
| 100 |
return return_value; |
| 101 |
} |
| 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 |
{ |
| 117 |
PyObject *return_value = NULL; |
| 118 |
int character; |
| 119 |
int _return_value; |
| 120 |
|
| 121 |
character = PyLong_AsInt(arg); |
| 122 |
if (character == -1 && PyErr_Occurred()) { |
| 123 |
goto exit; |
| 124 |
} |
| 125 |
_return_value = _sre_ascii_tolower_impl(module, character); |
| 126 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 127 |
goto exit; |
| 128 |
} |
| 129 |
return_value = PyLong_FromLong((long)_return_value); |
| 130 |
|
| 131 |
exit: |
| 132 |
return return_value; |
| 133 |
} |
| 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 |
{ |
| 149 |
PyObject *return_value = NULL; |
| 150 |
int character; |
| 151 |
int _return_value; |
| 152 |
|
| 153 |
character = PyLong_AsInt(arg); |
| 154 |
if (character == -1 && PyErr_Occurred()) { |
| 155 |
goto exit; |
| 156 |
} |
| 157 |
_return_value = _sre_unicode_tolower_impl(module, character); |
| 158 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 159 |
goto exit; |
| 160 |
} |
| 161 |
return_value = PyLong_FromLong((long)_return_value); |
| 162 |
|
| 163 |
exit: |
| 164 |
return return_value; |
| 165 |
} |
| 166 |
|
| 167 |
PyDoc_STRVAR(_sre_SRE_Pattern_match__doc__, |
| 168 |
"match($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_MATCH_METHODDEF \ |
| 174 |
{"match", _PyCFunction_CAST(_sre_SRE_Pattern_match), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Pattern_match__doc__}, |
| 175 |
|
| 176 |
static PyObject * |
| 177 |
_sre_SRE_Pattern_match_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_match(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 183 |
{ |
| 184 |
PyObject *return_value = NULL; |
| 185 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 186 |
|
| 187 |
#define NUM_KEYWORDS 3 |
| 188 |
static struct { |
| 189 |
PyGC_Head _this_is_not_used; |
| 190 |
PyObject_VAR_HEAD |
| 191 |
Py_hash_t ob_hash; |
| 192 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 193 |
} _kwtuple = { |
| 194 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 195 |
.ob_hash = -1, |
| 196 |
.ob_item = { &_Py_ID(string), &_Py_ID(pos), &_Py_ID(endpos), }, |
| 197 |
}; |
| 198 |
#undef NUM_KEYWORDS |
| 199 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 200 |
|
| 201 |
#else // !Py_BUILD_CORE |
| 202 |
# define KWTUPLE NULL |
| 203 |
#endif // !Py_BUILD_CORE |
| 204 |
|
| 205 |
static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; |
| 206 |
static _PyArg_Parser _parser = { |
| 207 |
.keywords = _keywords, |
| 208 |
.fname = "match", |
| 209 |
.kwtuple = KWTUPLE, |
| 210 |
}; |
| 211 |
#undef KWTUPLE |
| 212 |
PyObject *argsbuf[3]; |
| 213 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 214 |
PyObject *string; |
| 215 |
Py_ssize_t pos = 0; |
| 216 |
Py_ssize_t endpos = PY_SSIZE_T_MAX; |
| 217 |
|
| 218 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 219 |
/*minpos*/ 1, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 220 |
if (!args) { |
| 221 |
goto exit; |
| 222 |
} |
| 223 |
string = args[0]; |
| 224 |
if (!noptargs) { |
| 225 |
goto skip_optional_pos; |
| 226 |
} |
| 227 |
if (args[1]) { |
| 228 |
{ |
| 229 |
Py_ssize_t ival = -1; |
| 230 |
PyObject *iobj = _PyNumber_Index(args[1]); |
| 231 |
if (iobj != NULL) { |
| 232 |
ival = PyLong_AsSsize_t(iobj); |
| 233 |
Py_DECREF(iobj); |
| 234 |
} |
| 235 |
if (ival == -1 && PyErr_Occurred()) { |
| 236 |
goto exit; |
| 237 |
} |
| 238 |
pos = ival; |
| 239 |
} |
| 240 |
if (!--noptargs) { |
| 241 |
goto skip_optional_pos; |
| 242 |
} |
| 243 |
} |
| 244 |
{ |
| 245 |
Py_ssize_t ival = -1; |
| 246 |
PyObject *iobj = _PyNumber_Index(args[2]); |
| 247 |
if (iobj != NULL) { |
| 248 |
ival = PyLong_AsSsize_t(iobj); |
| 249 |
Py_DECREF(iobj); |
| 250 |
} |
| 251 |
if (ival == -1 && PyErr_Occurred()) { |
| 252 |
goto exit; |
| 253 |
} |
| 254 |
endpos = ival; |
| 255 |
} |
| 256 |
skip_optional_pos: |
| 257 |
return_value = _sre_SRE_Pattern_match_impl((PatternObject *)self, cls, string, pos, endpos); |
| 258 |
|
| 259 |
exit: |
| 260 |
return return_value; |
| 261 |
} |
| 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 |
{ |
| 280 |
PyObject *return_value = NULL; |
| 281 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 282 |
|
| 283 |
#define NUM_KEYWORDS 3 |
| 284 |
static struct { |
| 285 |
PyGC_Head _this_is_not_used; |
| 286 |
PyObject_VAR_HEAD |
| 287 |
Py_hash_t ob_hash; |
| 288 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 289 |
} _kwtuple = { |
| 290 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 291 |
.ob_hash = -1, |
| 292 |
.ob_item = { &_Py_ID(string), &_Py_ID(pos), &_Py_ID(endpos), }, |
| 293 |
}; |
| 294 |
#undef NUM_KEYWORDS |
| 295 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 296 |
|
| 297 |
#else // !Py_BUILD_CORE |
| 298 |
# define KWTUPLE NULL |
| 299 |
#endif // !Py_BUILD_CORE |
| 300 |
|
| 301 |
static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; |
| 302 |
static _PyArg_Parser _parser = { |
| 303 |
.keywords = _keywords, |
| 304 |
.fname = "fullmatch", |
| 305 |
.kwtuple = KWTUPLE, |
| 306 |
}; |
| 307 |
#undef KWTUPLE |
| 308 |
PyObject *argsbuf[3]; |
| 309 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 310 |
PyObject *string; |
| 311 |
Py_ssize_t pos = 0; |
| 312 |
Py_ssize_t endpos = PY_SSIZE_T_MAX; |
| 313 |
|
| 314 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 315 |
/*minpos*/ 1, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 316 |
if (!args) { |
| 317 |
goto exit; |
| 318 |
} |
| 319 |
string = args[0]; |
| 320 |
if (!noptargs) { |
| 321 |
goto skip_optional_pos; |
| 322 |
} |
| 323 |
if (args[1]) { |
| 324 |
{ |
| 325 |
Py_ssize_t ival = -1; |
| 326 |
PyObject *iobj = _PyNumber_Index(args[1]); |
| 327 |
if (iobj != NULL) { |
| 328 |
ival = PyLong_AsSsize_t(iobj); |
| 329 |
Py_DECREF(iobj); |
| 330 |
} |
| 331 |
if (ival == -1 && PyErr_Occurred()) { |
| 332 |
goto exit; |
| 333 |
} |
| 334 |
pos = ival; |
| 335 |
} |
| 336 |
if (!--noptargs) { |
| 337 |
goto skip_optional_pos; |
| 338 |
} |
| 339 |
} |
| 340 |
{ |
| 341 |
Py_ssize_t ival = -1; |
| 342 |
PyObject *iobj = _PyNumber_Index(args[2]); |
| 343 |
if (iobj != NULL) { |
| 344 |
ival = PyLong_AsSsize_t(iobj); |
| 345 |
Py_DECREF(iobj); |
| 346 |
} |
| 347 |
if (ival == -1 && PyErr_Occurred()) { |
| 348 |
goto exit; |
| 349 |
} |
| 350 |
endpos = ival; |
| 351 |
} |
| 352 |
skip_optional_pos: |
| 353 |
return_value = _sre_SRE_Pattern_fullmatch_impl((PatternObject *)self, cls, string, pos, endpos); |
| 354 |
|
| 355 |
exit: |
| 356 |
return return_value; |
| 357 |
} |
| 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 |
{ |
| 378 |
PyObject *return_value = NULL; |
| 379 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 380 |
|
| 381 |
#define NUM_KEYWORDS 3 |
| 382 |
static struct { |
| 383 |
PyGC_Head _this_is_not_used; |
| 384 |
PyObject_VAR_HEAD |
| 385 |
Py_hash_t ob_hash; |
| 386 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 387 |
} _kwtuple = { |
| 388 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 389 |
.ob_hash = -1, |
| 390 |
.ob_item = { &_Py_ID(string), &_Py_ID(pos), &_Py_ID(endpos), }, |
| 391 |
}; |
| 392 |
#undef NUM_KEYWORDS |
| 393 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 394 |
|
| 395 |
#else // !Py_BUILD_CORE |
| 396 |
# define KWTUPLE NULL |
| 397 |
#endif // !Py_BUILD_CORE |
| 398 |
|
| 399 |
static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; |
| 400 |
static _PyArg_Parser _parser = { |
| 401 |
.keywords = _keywords, |
| 402 |
.fname = "search", |
| 403 |
.kwtuple = KWTUPLE, |
| 404 |
}; |
| 405 |
#undef KWTUPLE |
| 406 |
PyObject *argsbuf[3]; |
| 407 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 408 |
PyObject *string; |
| 409 |
Py_ssize_t pos = 0; |
| 410 |
Py_ssize_t endpos = PY_SSIZE_T_MAX; |
| 411 |
|
| 412 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 413 |
/*minpos*/ 1, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 414 |
if (!args) { |
| 415 |
goto exit; |
| 416 |
} |
| 417 |
string = args[0]; |
| 418 |
if (!noptargs) { |
| 419 |
goto skip_optional_pos; |
| 420 |
} |
| 421 |
if (args[1]) { |
| 422 |
{ |
| 423 |
Py_ssize_t ival = -1; |
| 424 |
PyObject *iobj = _PyNumber_Index(args[1]); |
| 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 |
pos = ival; |
| 433 |
} |
| 434 |
if (!--noptargs) { |
| 435 |
goto skip_optional_pos; |
| 436 |
} |
| 437 |
} |
| 438 |
{ |
| 439 |
Py_ssize_t ival = -1; |
| 440 |
PyObject *iobj = _PyNumber_Index(args[2]); |
| 441 |
if (iobj != NULL) { |
| 442 |
ival = PyLong_AsSsize_t(iobj); |
| 443 |
Py_DECREF(iobj); |
| 444 |
} |
| 445 |
if (ival == -1 && PyErr_Occurred()) { |
| 446 |
goto exit; |
| 447 |
} |
| 448 |
endpos = ival; |
| 449 |
} |
| 450 |
skip_optional_pos: |
| 451 |
return_value = _sre_SRE_Pattern_search_impl((PatternObject *)self, cls, string, pos, endpos); |
| 452 |
|
| 453 |
exit: |
| 454 |
return return_value; |
| 455 |
} |
| 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 |
{ |
| 473 |
PyObject *return_value = NULL; |
| 474 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 475 |
|
| 476 |
#define NUM_KEYWORDS 3 |
| 477 |
static struct { |
| 478 |
PyGC_Head _this_is_not_used; |
| 479 |
PyObject_VAR_HEAD |
| 480 |
Py_hash_t ob_hash; |
| 481 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 482 |
} _kwtuple = { |
| 483 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 484 |
.ob_hash = -1, |
| 485 |
.ob_item = { &_Py_ID(string), &_Py_ID(pos), &_Py_ID(endpos), }, |
| 486 |
}; |
| 487 |
#undef NUM_KEYWORDS |
| 488 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 489 |
|
| 490 |
#else // !Py_BUILD_CORE |
| 491 |
# define KWTUPLE NULL |
| 492 |
#endif // !Py_BUILD_CORE |
| 493 |
|
| 494 |
static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; |
| 495 |
static _PyArg_Parser _parser = { |
| 496 |
.keywords = _keywords, |
| 497 |
.fname = "findall", |
| 498 |
.kwtuple = KWTUPLE, |
| 499 |
}; |
| 500 |
#undef KWTUPLE |
| 501 |
PyObject *argsbuf[3]; |
| 502 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 503 |
PyObject *string; |
| 504 |
Py_ssize_t pos = 0; |
| 505 |
Py_ssize_t endpos = PY_SSIZE_T_MAX; |
| 506 |
|
| 507 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 508 |
/*minpos*/ 1, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 509 |
if (!args) { |
| 510 |
goto exit; |
| 511 |
} |
| 512 |
string = args[0]; |
| 513 |
if (!noptargs) { |
| 514 |
goto skip_optional_pos; |
| 515 |
} |
| 516 |
if (args[1]) { |
| 517 |
{ |
| 518 |
Py_ssize_t ival = -1; |
| 519 |
PyObject *iobj = _PyNumber_Index(args[1]); |
| 520 |
if (iobj != NULL) { |
| 521 |
ival = PyLong_AsSsize_t(iobj); |
| 522 |
Py_DECREF(iobj); |
| 523 |
} |
| 524 |
if (ival == -1 && PyErr_Occurred()) { |
| 525 |
goto exit; |
| 526 |
} |
| 527 |
pos = ival; |
| 528 |
} |
| 529 |
if (!--noptargs) { |
| 530 |
goto skip_optional_pos; |
| 531 |
} |
| 532 |
} |
| 533 |
{ |
| 534 |
Py_ssize_t ival = -1; |
| 535 |
PyObject *iobj = _PyNumber_Index(args[2]); |
| 536 |
if (iobj != NULL) { |
| 537 |
ival = PyLong_AsSsize_t(iobj); |
| 538 |
Py_DECREF(iobj); |
| 539 |
} |
| 540 |
if (ival == -1 && PyErr_Occurred()) { |
| 541 |
goto exit; |
| 542 |
} |
| 543 |
endpos = ival; |
| 544 |
} |
| 545 |
skip_optional_pos: |
| 546 |
return_value = _sre_SRE_Pattern_findall_impl((PatternObject *)self, string, pos, endpos); |
| 547 |
|
| 548 |
exit: |
| 549 |
return return_value; |
| 550 |
} |
| 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 |
{ |
| 571 |
PyObject *return_value = NULL; |
| 572 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 573 |
|
| 574 |
#define NUM_KEYWORDS 3 |
| 575 |
static struct { |
| 576 |
PyGC_Head _this_is_not_used; |
| 577 |
PyObject_VAR_HEAD |
| 578 |
Py_hash_t ob_hash; |
| 579 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 580 |
} _kwtuple = { |
| 581 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 582 |
.ob_hash = -1, |
| 583 |
.ob_item = { &_Py_ID(string), &_Py_ID(pos), &_Py_ID(endpos), }, |
| 584 |
}; |
| 585 |
#undef NUM_KEYWORDS |
| 586 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 587 |
|
| 588 |
#else // !Py_BUILD_CORE |
| 589 |
# define KWTUPLE NULL |
| 590 |
#endif // !Py_BUILD_CORE |
| 591 |
|
| 592 |
static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; |
| 593 |
static _PyArg_Parser _parser = { |
| 594 |
.keywords = _keywords, |
| 595 |
.fname = "finditer", |
| 596 |
.kwtuple = KWTUPLE, |
| 597 |
}; |
| 598 |
#undef KWTUPLE |
| 599 |
PyObject *argsbuf[3]; |
| 600 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 601 |
PyObject *string; |
| 602 |
Py_ssize_t pos = 0; |
| 603 |
Py_ssize_t endpos = PY_SSIZE_T_MAX; |
| 604 |
|
| 605 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 606 |
/*minpos*/ 1, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 607 |
if (!args) { |
| 608 |
goto exit; |
| 609 |
} |
| 610 |
string = args[0]; |
| 611 |
if (!noptargs) { |
| 612 |
goto skip_optional_pos; |
| 613 |
} |
| 614 |
if (args[1]) { |
| 615 |
{ |
| 616 |
Py_ssize_t ival = -1; |
| 617 |
PyObject *iobj = _PyNumber_Index(args[1]); |
| 618 |
if (iobj != NULL) { |
| 619 |
ival = PyLong_AsSsize_t(iobj); |
| 620 |
Py_DECREF(iobj); |
| 621 |
} |
| 622 |
if (ival == -1 && PyErr_Occurred()) { |
| 623 |
goto exit; |
| 624 |
} |
| 625 |
pos = ival; |
| 626 |
} |
| 627 |
if (!--noptargs) { |
| 628 |
goto skip_optional_pos; |
| 629 |
} |
| 630 |
} |
| 631 |
{ |
| 632 |
Py_ssize_t ival = -1; |
| 633 |
PyObject *iobj = _PyNumber_Index(args[2]); |
| 634 |
if (iobj != NULL) { |
| 635 |
ival = PyLong_AsSsize_t(iobj); |
| 636 |
Py_DECREF(iobj); |
| 637 |
} |
| 638 |
if (ival == -1 && PyErr_Occurred()) { |
| 639 |
goto exit; |
| 640 |
} |
| 641 |
endpos = ival; |
| 642 |
} |
| 643 |
skip_optional_pos: |
| 644 |
return_value = _sre_SRE_Pattern_finditer_impl((PatternObject *)self, cls, string, pos, endpos); |
| 645 |
|
| 646 |
exit: |
| 647 |
return return_value; |
| 648 |
} |
| 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 |
{ |
| 666 |
PyObject *return_value = NULL; |
| 667 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 668 |
|
| 669 |
#define NUM_KEYWORDS 3 |
| 670 |
static struct { |
| 671 |
PyGC_Head _this_is_not_used; |
| 672 |
PyObject_VAR_HEAD |
| 673 |
Py_hash_t ob_hash; |
| 674 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 675 |
} _kwtuple = { |
| 676 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 677 |
.ob_hash = -1, |
| 678 |
.ob_item = { &_Py_ID(string), &_Py_ID(pos), &_Py_ID(endpos), }, |
| 679 |
}; |
| 680 |
#undef NUM_KEYWORDS |
| 681 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 682 |
|
| 683 |
#else // !Py_BUILD_CORE |
| 684 |
# define KWTUPLE NULL |
| 685 |
#endif // !Py_BUILD_CORE |
| 686 |
|
| 687 |
static const char * const _keywords[] = {"string", "pos", "endpos", NULL}; |
| 688 |
static _PyArg_Parser _parser = { |
| 689 |
.keywords = _keywords, |
| 690 |
.fname = "scanner", |
| 691 |
.kwtuple = KWTUPLE, |
| 692 |
}; |
| 693 |
#undef KWTUPLE |
| 694 |
PyObject *argsbuf[3]; |
| 695 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 696 |
PyObject *string; |
| 697 |
Py_ssize_t pos = 0; |
| 698 |
Py_ssize_t endpos = PY_SSIZE_T_MAX; |
| 699 |
|
| 700 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 701 |
/*minpos*/ 1, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 702 |
if (!args) { |
| 703 |
goto exit; |
| 704 |
} |
| 705 |
string = args[0]; |
| 706 |
if (!noptargs) { |
| 707 |
goto skip_optional_pos; |
| 708 |
} |
| 709 |
if (args[1]) { |
| 710 |
{ |
| 711 |
Py_ssize_t ival = -1; |
| 712 |
PyObject *iobj = _PyNumber_Index(args[1]); |
| 713 |
if (iobj != NULL) { |
| 714 |
ival = PyLong_AsSsize_t(iobj); |
| 715 |
Py_DECREF(iobj); |
| 716 |
} |
| 717 |
if (ival == -1 && PyErr_Occurred()) { |
| 718 |
goto exit; |
| 719 |
} |
| 720 |
pos = ival; |
| 721 |
} |
| 722 |
if (!--noptargs) { |
| 723 |
goto skip_optional_pos; |
| 724 |
} |
| 725 |
} |
| 726 |
{ |
| 727 |
Py_ssize_t ival = -1; |
| 728 |
PyObject *iobj = _PyNumber_Index(args[2]); |
| 729 |
if (iobj != NULL) { |
| 730 |
ival = PyLong_AsSsize_t(iobj); |
| 731 |
Py_DECREF(iobj); |
| 732 |
} |
| 733 |
if (ival == -1 && PyErr_Occurred()) { |
| 734 |
goto exit; |
| 735 |
} |
| 736 |
endpos = ival; |
| 737 |
} |
| 738 |
skip_optional_pos: |
| 739 |
return_value = _sre_SRE_Pattern_scanner_impl((PatternObject *)self, cls, string, pos, endpos); |
| 740 |
|
| 741 |
exit: |
| 742 |
return return_value; |
| 743 |
} |
| 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 |
{ |
| 761 |
PyObject *return_value = NULL; |
| 762 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 763 |
|
| 764 |
#define NUM_KEYWORDS 2 |
| 765 |
static struct { |
| 766 |
PyGC_Head _this_is_not_used; |
| 767 |
PyObject_VAR_HEAD |
| 768 |
Py_hash_t ob_hash; |
| 769 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 770 |
} _kwtuple = { |
| 771 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 772 |
.ob_hash = -1, |
| 773 |
.ob_item = { &_Py_ID(string), &_Py_ID(maxsplit), }, |
| 774 |
}; |
| 775 |
#undef NUM_KEYWORDS |
| 776 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 777 |
|
| 778 |
#else // !Py_BUILD_CORE |
| 779 |
# define KWTUPLE NULL |
| 780 |
#endif // !Py_BUILD_CORE |
| 781 |
|
| 782 |
static const char * const _keywords[] = {"string", "maxsplit", NULL}; |
| 783 |
static _PyArg_Parser _parser = { |
| 784 |
.keywords = _keywords, |
| 785 |
.fname = "split", |
| 786 |
.kwtuple = KWTUPLE, |
| 787 |
}; |
| 788 |
#undef KWTUPLE |
| 789 |
PyObject *argsbuf[2]; |
| 790 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 791 |
PyObject *string; |
| 792 |
Py_ssize_t maxsplit = 0; |
| 793 |
|
| 794 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 795 |
/*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 796 |
if (!args) { |
| 797 |
goto exit; |
| 798 |
} |
| 799 |
string = args[0]; |
| 800 |
if (!noptargs) { |
| 801 |
goto skip_optional_pos; |
| 802 |
} |
| 803 |
{ |
| 804 |
Py_ssize_t ival = -1; |
| 805 |
PyObject *iobj = _PyNumber_Index(args[1]); |
| 806 |
if (iobj != NULL) { |
| 807 |
ival = PyLong_AsSsize_t(iobj); |
| 808 |
Py_DECREF(iobj); |
| 809 |
} |
| 810 |
if (ival == -1 && PyErr_Occurred()) { |
| 811 |
goto exit; |
| 812 |
} |
| 813 |
maxsplit = ival; |
| 814 |
} |
| 815 |
skip_optional_pos: |
| 816 |
return_value = _sre_SRE_Pattern_split_impl((PatternObject *)self, string, maxsplit); |
| 817 |
|
| 818 |
exit: |
| 819 |
return return_value; |
| 820 |
} |
| 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 |
{ |
| 838 |
PyObject *return_value = NULL; |
| 839 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 840 |
|
| 841 |
#define NUM_KEYWORDS 3 |
| 842 |
static struct { |
| 843 |
PyGC_Head _this_is_not_used; |
| 844 |
PyObject_VAR_HEAD |
| 845 |
Py_hash_t ob_hash; |
| 846 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 847 |
} _kwtuple = { |
| 848 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 849 |
.ob_hash = -1, |
| 850 |
.ob_item = { &_Py_ID(repl), &_Py_ID(string), &_Py_ID(count), }, |
| 851 |
}; |
| 852 |
#undef NUM_KEYWORDS |
| 853 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 854 |
|
| 855 |
#else // !Py_BUILD_CORE |
| 856 |
# define KWTUPLE NULL |
| 857 |
#endif // !Py_BUILD_CORE |
| 858 |
|
| 859 |
static const char * const _keywords[] = {"repl", "string", "count", NULL}; |
| 860 |
static _PyArg_Parser _parser = { |
| 861 |
.keywords = _keywords, |
| 862 |
.fname = "sub", |
| 863 |
.kwtuple = KWTUPLE, |
| 864 |
}; |
| 865 |
#undef KWTUPLE |
| 866 |
PyObject *argsbuf[3]; |
| 867 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; |
| 868 |
PyObject *repl; |
| 869 |
PyObject *string; |
| 870 |
Py_ssize_t count = 0; |
| 871 |
|
| 872 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 873 |
/*minpos*/ 2, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 874 |
if (!args) { |
| 875 |
goto exit; |
| 876 |
} |
| 877 |
repl = args[0]; |
| 878 |
string = args[1]; |
| 879 |
if (!noptargs) { |
| 880 |
goto skip_optional_pos; |
| 881 |
} |
| 882 |
{ |
| 883 |
Py_ssize_t ival = -1; |
| 884 |
PyObject *iobj = _PyNumber_Index(args[2]); |
| 885 |
if (iobj != NULL) { |
| 886 |
ival = PyLong_AsSsize_t(iobj); |
| 887 |
Py_DECREF(iobj); |
| 888 |
} |
| 889 |
if (ival == -1 && PyErr_Occurred()) { |
| 890 |
goto exit; |
| 891 |
} |
| 892 |
count = ival; |
| 893 |
} |
| 894 |
skip_optional_pos: |
| 895 |
return_value = _sre_SRE_Pattern_sub_impl((PatternObject *)self, cls, repl, string, count); |
| 896 |
|
| 897 |
exit: |
| 898 |
return return_value; |
| 899 |
} |
| 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 |
{ |
| 918 |
PyObject *return_value = NULL; |
| 919 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 920 |
|
| 921 |
#define NUM_KEYWORDS 3 |
| 922 |
static struct { |
| 923 |
PyGC_Head _this_is_not_used; |
| 924 |
PyObject_VAR_HEAD |
| 925 |
Py_hash_t ob_hash; |
| 926 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 927 |
} _kwtuple = { |
| 928 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 929 |
.ob_hash = -1, |
| 930 |
.ob_item = { &_Py_ID(repl), &_Py_ID(string), &_Py_ID(count), }, |
| 931 |
}; |
| 932 |
#undef NUM_KEYWORDS |
| 933 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 934 |
|
| 935 |
#else // !Py_BUILD_CORE |
| 936 |
# define KWTUPLE NULL |
| 937 |
#endif // !Py_BUILD_CORE |
| 938 |
|
| 939 |
static const char * const _keywords[] = {"repl", "string", "count", NULL}; |
| 940 |
static _PyArg_Parser _parser = { |
| 941 |
.keywords = _keywords, |
| 942 |
.fname = "subn", |
| 943 |
.kwtuple = KWTUPLE, |
| 944 |
}; |
| 945 |
#undef KWTUPLE |
| 946 |
PyObject *argsbuf[3]; |
| 947 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; |
| 948 |
PyObject *repl; |
| 949 |
PyObject *string; |
| 950 |
Py_ssize_t count = 0; |
| 951 |
|
| 952 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 953 |
/*minpos*/ 2, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 954 |
if (!args) { |
| 955 |
goto exit; |
| 956 |
} |
| 957 |
repl = args[0]; |
| 958 |
string = args[1]; |
| 959 |
if (!noptargs) { |
| 960 |
goto skip_optional_pos; |
| 961 |
} |
| 962 |
{ |
| 963 |
Py_ssize_t ival = -1; |
| 964 |
PyObject *iobj = _PyNumber_Index(args[2]); |
| 965 |
if (iobj != NULL) { |
| 966 |
ival = PyLong_AsSsize_t(iobj); |
| 967 |
Py_DECREF(iobj); |
| 968 |
} |
| 969 |
if (ival == -1 && PyErr_Occurred()) { |
| 970 |
goto exit; |
| 971 |
} |
| 972 |
count = ival; |
| 973 |
} |
| 974 |
skip_optional_pos: |
| 975 |
return_value = _sre_SRE_Pattern_subn_impl((PatternObject *)self, cls, repl, string, count); |
| 976 |
|
| 977 |
exit: |
| 978 |
return return_value; |
| 979 |
} |
| 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 |
{ |
| 995 |
return _sre_SRE_Pattern___copy___impl((PatternObject *)self); |
| 996 |
} |
| 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 |
{ |
| 1012 |
PyObject *return_value = NULL; |
| 1013 |
|
| 1014 |
return_value = _sre_SRE_Pattern___deepcopy___impl((PatternObject *)self, memo); |
| 1015 |
|
| 1016 |
return return_value; |
| 1017 |
} |
| 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 |
{ |
| 1074 |
PyObject *return_value = NULL; |
| 1075 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 1076 |
|
| 1077 |
#define NUM_KEYWORDS 6 |
| 1078 |
static struct { |
| 1079 |
PyGC_Head _this_is_not_used; |
| 1080 |
PyObject_VAR_HEAD |
| 1081 |
Py_hash_t ob_hash; |
| 1082 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 1083 |
} _kwtuple = { |
| 1084 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 1085 |
.ob_hash = -1, |
| 1086 |
.ob_item = { &_Py_ID(pattern), &_Py_ID(flags), &_Py_ID(code), &_Py_ID(groups), &_Py_ID(groupindex), &_Py_ID(indexgroup), }, |
| 1087 |
}; |
| 1088 |
#undef NUM_KEYWORDS |
| 1089 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 1090 |
|
| 1091 |
#else // !Py_BUILD_CORE |
| 1092 |
# define KWTUPLE NULL |
| 1093 |
#endif // !Py_BUILD_CORE |
| 1094 |
|
| 1095 |
static const char * const _keywords[] = {"pattern", "flags", "code", "groups", "groupindex", "indexgroup", NULL}; |
| 1096 |
static _PyArg_Parser _parser = { |
| 1097 |
.keywords = _keywords, |
| 1098 |
.fname = "compile", |
| 1099 |
.kwtuple = KWTUPLE, |
| 1100 |
}; |
| 1101 |
#undef KWTUPLE |
| 1102 |
PyObject *argsbuf[6]; |
| 1103 |
PyObject *pattern; |
| 1104 |
int flags; |
| 1105 |
PyObject *code; |
| 1106 |
Py_ssize_t groups; |
| 1107 |
PyObject *groupindex; |
| 1108 |
PyObject *indexgroup; |
| 1109 |
|
| 1110 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 1111 |
/*minpos*/ 6, /*maxpos*/ 6, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 1112 |
if (!args) { |
| 1113 |
goto exit; |
| 1114 |
} |
| 1115 |
pattern = args[0]; |
| 1116 |
flags = PyLong_AsInt(args[1]); |
| 1117 |
if (flags == -1 && PyErr_Occurred()) { |
| 1118 |
goto exit; |
| 1119 |
} |
| 1120 |
if (!PyList_Check(args[2])) { |
| 1121 |
_PyArg_BadArgument("compile", "argument 'code'", "list", args[2]); |
| 1122 |
goto exit; |
| 1123 |
} |
| 1124 |
code = args[2]; |
| 1125 |
{ |
| 1126 |
Py_ssize_t ival = -1; |
| 1127 |
PyObject *iobj = _PyNumber_Index(args[3]); |
| 1128 |
if (iobj != NULL) { |
| 1129 |
ival = PyLong_AsSsize_t(iobj); |
| 1130 |
Py_DECREF(iobj); |
| 1131 |
} |
| 1132 |
if (ival == -1 && PyErr_Occurred()) { |
| 1133 |
goto exit; |
| 1134 |
} |
| 1135 |
groups = ival; |
| 1136 |
} |
| 1137 |
if (!PyDict_Check(args[4])) { |
| 1138 |
_PyArg_BadArgument("compile", "argument 'groupindex'", "dict", args[4]); |
| 1139 |
goto exit; |
| 1140 |
} |
| 1141 |
groupindex = args[4]; |
| 1142 |
if (!PyTuple_Check(args[5])) { |
| 1143 |
_PyArg_BadArgument("compile", "argument 'indexgroup'", "tuple", args[5]); |
| 1144 |
goto exit; |
| 1145 |
} |
| 1146 |
indexgroup = args[5]; |
| 1147 |
return_value = _sre_compile_impl(module, pattern, flags, code, groups, groupindex, indexgroup); |
| 1148 |
|
| 1149 |
exit: |
| 1150 |
return return_value; |
| 1151 |
} |
| 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 |
{ |
| 1173 |
PyObject *return_value = NULL; |
| 1174 |
PyObject *pattern; |
| 1175 |
PyObject *template; |
| 1176 |
|
| 1177 |
if (!_PyArg_CheckPositional("template", nargs, 2, 2)) { |
| 1178 |
goto exit; |
| 1179 |
} |
| 1180 |
pattern = args[0]; |
| 1181 |
if (!PyList_Check(args[1])) { |
| 1182 |
_PyArg_BadArgument("template", "argument 2", "list", args[1]); |
| 1183 |
goto exit; |
| 1184 |
} |
| 1185 |
template = args[1]; |
| 1186 |
return_value = _sre_template_impl(module, pattern, template); |
| 1187 |
|
| 1188 |
exit: |
| 1189 |
return return_value; |
| 1190 |
} |
| 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 |
{ |
| 1207 |
PyObject *return_value = NULL; |
| 1208 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 1209 |
|
| 1210 |
#define NUM_KEYWORDS 1 |
| 1211 |
static struct { |
| 1212 |
PyGC_Head _this_is_not_used; |
| 1213 |
PyObject_VAR_HEAD |
| 1214 |
Py_hash_t ob_hash; |
| 1215 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 1216 |
} _kwtuple = { |
| 1217 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 1218 |
.ob_hash = -1, |
| 1219 |
.ob_item = { &_Py_ID(template), }, |
| 1220 |
}; |
| 1221 |
#undef NUM_KEYWORDS |
| 1222 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 1223 |
|
| 1224 |
#else // !Py_BUILD_CORE |
| 1225 |
# define KWTUPLE NULL |
| 1226 |
#endif // !Py_BUILD_CORE |
| 1227 |
|
| 1228 |
static const char * const _keywords[] = {"template", NULL}; |
| 1229 |
static _PyArg_Parser _parser = { |
| 1230 |
.keywords = _keywords, |
| 1231 |
.fname = "expand", |
| 1232 |
.kwtuple = KWTUPLE, |
| 1233 |
}; |
| 1234 |
#undef KWTUPLE |
| 1235 |
PyObject *argsbuf[1]; |
| 1236 |
PyObject *template; |
| 1237 |
|
| 1238 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 1239 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 1240 |
if (!args) { |
| 1241 |
goto exit; |
| 1242 |
} |
| 1243 |
template = args[0]; |
| 1244 |
return_value = _sre_SRE_Match_expand_impl((MatchObject *)self, template); |
| 1245 |
|
| 1246 |
exit: |
| 1247 |
return return_value; |
| 1248 |
} |
| 1249 |
|
| 1250 |
PyDoc_STRVAR(_sre_SRE_Match_groups__doc__, |
| 1251 |
"groups($self, /, default=None)\n" |
| 1252 |
"--\n" |
| 1253 |
"\n" |
| 1254 |
"Return a tuple containing all the subgroups of the match, from 1.\n" |
| 1255 |
"\n" |
| 1256 |
" default\n" |
| 1257 |
" Is used for groups that did not participate in the match."); |
| 1258 |
|
| 1259 |
#define _SRE_SRE_MATCH_GROUPS_METHODDEF \ |
| 1260 |
{"groups", _PyCFunction_CAST(_sre_SRE_Match_groups), METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Match_groups__doc__}, |
| 1261 |
|
| 1262 |
static PyObject * |
| 1263 |
_sre_SRE_Match_groups_impl(MatchObject *self, PyObject *default_value); |
| 1264 |
|
| 1265 |
static PyObject * |
| 1266 |
_sre_SRE_Match_groups(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 1267 |
{ |
| 1268 |
PyObject *return_value = NULL; |
| 1269 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 1270 |
|
| 1271 |
#define NUM_KEYWORDS 1 |
| 1272 |
static struct { |
| 1273 |
PyGC_Head _this_is_not_used; |
| 1274 |
PyObject_VAR_HEAD |
| 1275 |
Py_hash_t ob_hash; |
| 1276 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 1277 |
} _kwtuple = { |
| 1278 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 1279 |
.ob_hash = -1, |
| 1280 |
.ob_item = { &_Py_ID(default), }, |
| 1281 |
}; |
| 1282 |
#undef NUM_KEYWORDS |
| 1283 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 1284 |
|
| 1285 |
#else // !Py_BUILD_CORE |
| 1286 |
# define KWTUPLE NULL |
| 1287 |
#endif // !Py_BUILD_CORE |
| 1288 |
|
| 1289 |
static const char * const _keywords[] = {"default", NULL}; |
| 1290 |
static _PyArg_Parser _parser = { |
| 1291 |
.keywords = _keywords, |
| 1292 |
.fname = "groups", |
| 1293 |
.kwtuple = KWTUPLE, |
| 1294 |
}; |
| 1295 |
#undef KWTUPLE |
| 1296 |
PyObject *argsbuf[1]; |
| 1297 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
| 1298 |
PyObject *default_value = Py_None; |
| 1299 |
|
| 1300 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 1301 |
/*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 1302 |
if (!args) { |
| 1303 |
goto exit; |
| 1304 |
} |
| 1305 |
if (!noptargs) { |
| 1306 |
goto skip_optional_pos; |
| 1307 |
} |
| 1308 |
default_value = args[0]; |
| 1309 |
skip_optional_pos: |
| 1310 |
return_value = _sre_SRE_Match_groups_impl((MatchObject *)self, default_value); |
| 1311 |
|
| 1312 |
exit: |
| 1313 |
return return_value; |
| 1314 |
} |
| 1315 |
|
| 1316 |
PyDoc_STRVAR(_sre_SRE_Match_groupdict__doc__, |
| 1317 |
"groupdict($self, /, default=None)\n" |
| 1318 |
"--\n" |
| 1319 |
"\n" |
| 1320 |
"Return a dictionary containing all the named subgroups of the match, keyed by the subgroup name.\n" |
| 1321 |
"\n" |
| 1322 |
" default\n" |
| 1323 |
" Is used for groups that did not participate in the match."); |
| 1324 |
|
| 1325 |
#define _SRE_SRE_MATCH_GROUPDICT_METHODDEF \ |
| 1326 |
{"groupdict", _PyCFunction_CAST(_sre_SRE_Match_groupdict), METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Match_groupdict__doc__}, |
| 1327 |
|
| 1328 |
static PyObject * |
| 1329 |
_sre_SRE_Match_groupdict_impl(MatchObject *self, PyObject *default_value); |
| 1330 |
|
| 1331 |
static PyObject * |
| 1332 |
_sre_SRE_Match_groupdict(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 1333 |
{ |
| 1334 |
PyObject *return_value = NULL; |
| 1335 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 1336 |
|
| 1337 |
#define NUM_KEYWORDS 1 |
| 1338 |
static struct { |
| 1339 |
PyGC_Head _this_is_not_used; |
| 1340 |
PyObject_VAR_HEAD |
| 1341 |
Py_hash_t ob_hash; |
| 1342 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 1343 |
} _kwtuple = { |
| 1344 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 1345 |
.ob_hash = -1, |
| 1346 |
.ob_item = { &_Py_ID(default), }, |
| 1347 |
}; |
| 1348 |
#undef NUM_KEYWORDS |
| 1349 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 1350 |
|
| 1351 |
#else // !Py_BUILD_CORE |
| 1352 |
# define KWTUPLE NULL |
| 1353 |
#endif // !Py_BUILD_CORE |
| 1354 |
|
| 1355 |
static const char * const _keywords[] = {"default", NULL}; |
| 1356 |
static _PyArg_Parser _parser = { |
| 1357 |
.keywords = _keywords, |
| 1358 |
.fname = "groupdict", |
| 1359 |
.kwtuple = KWTUPLE, |
| 1360 |
}; |
| 1361 |
#undef KWTUPLE |
| 1362 |
PyObject *argsbuf[1]; |
| 1363 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
| 1364 |
PyObject *default_value = Py_None; |
| 1365 |
|
| 1366 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 1367 |
/*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 1368 |
if (!args) { |
| 1369 |
goto exit; |
| 1370 |
} |
| 1371 |
if (!noptargs) { |
| 1372 |
goto skip_optional_pos; |
| 1373 |
} |
| 1374 |
default_value = args[0]; |
| 1375 |
skip_optional_pos: |
| 1376 |
return_value = _sre_SRE_Match_groupdict_impl((MatchObject *)self, default_value); |
| 1377 |
|
| 1378 |
exit: |
| 1379 |
return return_value; |
| 1380 |
} |
| 1381 |
|
| 1382 |
PyDoc_STRVAR(_sre_SRE_Match_start__doc__, |
| 1383 |
"start($self, group=0, /)\n" |
| 1384 |
"--\n" |
| 1385 |
"\n" |
| 1386 |
"Return index of the start of the substring matched by group."); |
| 1387 |
|
| 1388 |
#define _SRE_SRE_MATCH_START_METHODDEF \ |
| 1389 |
{"start", _PyCFunction_CAST(_sre_SRE_Match_start), METH_FASTCALL, _sre_SRE_Match_start__doc__}, |
| 1390 |
|
| 1391 |
static Py_ssize_t |
| 1392 |
_sre_SRE_Match_start_impl(MatchObject *self, PyObject *group); |
| 1393 |
|
| 1394 |
static PyObject * |
| 1395 |
_sre_SRE_Match_start(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
| 1396 |
{ |
| 1397 |
PyObject *return_value = NULL; |
| 1398 |
PyObject *group = NULL; |
| 1399 |
Py_ssize_t _return_value; |
| 1400 |
|
| 1401 |
if (!_PyArg_CheckPositional("start", nargs, 0, 1)) { |
| 1402 |
goto exit; |
| 1403 |
} |
| 1404 |
if (nargs < 1) { |
| 1405 |
goto skip_optional; |
| 1406 |
} |
| 1407 |
group = args[0]; |
| 1408 |
skip_optional: |
| 1409 |
_return_value = _sre_SRE_Match_start_impl((MatchObject *)self, group); |
| 1410 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 1411 |
goto exit; |
| 1412 |
} |
| 1413 |
return_value = PyLong_FromSsize_t(_return_value); |
| 1414 |
|
| 1415 |
exit: |
| 1416 |
return return_value; |
| 1417 |
} |
| 1418 |
|
| 1419 |
PyDoc_STRVAR(_sre_SRE_Match_end__doc__, |
| 1420 |
"end($self, group=0, /)\n" |
| 1421 |
"--\n" |
| 1422 |
"\n" |
| 1423 |
"Return index of the end of the substring matched by group."); |
| 1424 |
|
| 1425 |
#define _SRE_SRE_MATCH_END_METHODDEF \ |
| 1426 |
{"end", _PyCFunction_CAST(_sre_SRE_Match_end), METH_FASTCALL, _sre_SRE_Match_end__doc__}, |
| 1427 |
|
| 1428 |
static Py_ssize_t |
| 1429 |
_sre_SRE_Match_end_impl(MatchObject *self, PyObject *group); |
| 1430 |
|
| 1431 |
static PyObject * |
| 1432 |
_sre_SRE_Match_end(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
| 1433 |
{ |
| 1434 |
PyObject *return_value = NULL; |
| 1435 |
PyObject *group = NULL; |
| 1436 |
Py_ssize_t _return_value; |
| 1437 |
|
| 1438 |
if (!_PyArg_CheckPositional("end", nargs, 0, 1)) { |
| 1439 |
goto exit; |
| 1440 |
} |
| 1441 |
if (nargs < 1) { |
| 1442 |
goto skip_optional; |
| 1443 |
} |
| 1444 |
group = args[0]; |
| 1445 |
skip_optional: |
| 1446 |
_return_value = _sre_SRE_Match_end_impl((MatchObject *)self, group); |
| 1447 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 1448 |
goto exit; |
| 1449 |
} |
| 1450 |
return_value = PyLong_FromSsize_t(_return_value); |
| 1451 |
|
| 1452 |
exit: |
| 1453 |
return return_value; |
| 1454 |
} |
| 1455 |
|
| 1456 |
PyDoc_STRVAR(_sre_SRE_Match_span__doc__, |
| 1457 |
"span($self, group=0, /)\n" |
| 1458 |
"--\n" |
| 1459 |
"\n" |
| 1460 |
"For match object m, return the 2-tuple (m.start(group), m.end(group))."); |
| 1461 |
|
| 1462 |
#define _SRE_SRE_MATCH_SPAN_METHODDEF \ |
| 1463 |
{"span", _PyCFunction_CAST(_sre_SRE_Match_span), METH_FASTCALL, _sre_SRE_Match_span__doc__}, |
| 1464 |
|
| 1465 |
static PyObject * |
| 1466 |
_sre_SRE_Match_span_impl(MatchObject *self, PyObject *group); |
| 1467 |
|
| 1468 |
static PyObject * |
| 1469 |
_sre_SRE_Match_span(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
| 1470 |
{ |
| 1471 |
PyObject *return_value = NULL; |
| 1472 |
PyObject *group = NULL; |
| 1473 |
|
| 1474 |
if (!_PyArg_CheckPositional("span", nargs, 0, 1)) { |
| 1475 |
goto exit; |
| 1476 |
} |
| 1477 |
if (nargs < 1) { |
| 1478 |
goto skip_optional; |
| 1479 |
} |
| 1480 |
group = args[0]; |
| 1481 |
skip_optional: |
| 1482 |
return_value = _sre_SRE_Match_span_impl((MatchObject *)self, group); |
| 1483 |
|
| 1484 |
exit: |
| 1485 |
return return_value; |
| 1486 |
} |
| 1487 |
|
| 1488 |
PyDoc_STRVAR(_sre_SRE_Match___copy____doc__, |
| 1489 |
"__copy__($self, /)\n" |
| 1490 |
"--\n" |
| 1491 |
"\n"); |
| 1492 |
|
| 1493 |
#define _SRE_SRE_MATCH___COPY___METHODDEF \ |
| 1494 |
{"__copy__", (PyCFunction)_sre_SRE_Match___copy__, METH_NOARGS, _sre_SRE_Match___copy____doc__}, |
| 1495 |
|
| 1496 |
static PyObject * |
| 1497 |
_sre_SRE_Match___copy___impl(MatchObject *self); |
| 1498 |
|
| 1499 |
static PyObject * |
| 1500 |
_sre_SRE_Match___copy__(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 1501 |
{ |
| 1502 |
return _sre_SRE_Match___copy___impl((MatchObject *)self); |
| 1503 |
} |
| 1504 |
|
| 1505 |
PyDoc_STRVAR(_sre_SRE_Match___deepcopy____doc__, |
| 1506 |
"__deepcopy__($self, memo, /)\n" |
| 1507 |
"--\n" |
| 1508 |
"\n"); |
| 1509 |
|
| 1510 |
#define _SRE_SRE_MATCH___DEEPCOPY___METHODDEF \ |
| 1511 |
{"__deepcopy__", (PyCFunction)_sre_SRE_Match___deepcopy__, METH_O, _sre_SRE_Match___deepcopy____doc__}, |
| 1512 |
|
| 1513 |
static PyObject * |
| 1514 |
_sre_SRE_Match___deepcopy___impl(MatchObject *self, PyObject *memo); |
| 1515 |
|
| 1516 |
static PyObject * |
| 1517 |
_sre_SRE_Match___deepcopy__(PyObject *self, PyObject *memo) |
| 1518 |
{ |
| 1519 |
PyObject *return_value = NULL; |
| 1520 |
|
| 1521 |
return_value = _sre_SRE_Match___deepcopy___impl((MatchObject *)self, memo); |
| 1522 |
|
| 1523 |
return return_value; |
| 1524 |
} |
| 1525 |
|
| 1526 |
PyDoc_STRVAR(_sre_SRE_Scanner_match__doc__, |
| 1527 |
"match($self, /)\n" |
| 1528 |
"--\n" |
| 1529 |
"\n"); |
| 1530 |
|
| 1531 |
#define _SRE_SRE_SCANNER_MATCH_METHODDEF \ |
| 1532 |
{"match", _PyCFunction_CAST(_sre_SRE_Scanner_match), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Scanner_match__doc__}, |
| 1533 |
|
| 1534 |
static PyObject * |
| 1535 |
_sre_SRE_Scanner_match_impl(ScannerObject *self, PyTypeObject *cls); |
| 1536 |
|
| 1537 |
static PyObject * |
| 1538 |
_sre_SRE_Scanner_match(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 1539 |
{ |
| 1540 |
if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) { |
| 1541 |
PyErr_SetString(PyExc_TypeError, "match() takes no arguments"); |
| 1542 |
return NULL; |
| 1543 |
} |
| 1544 |
return _sre_SRE_Scanner_match_impl((ScannerObject *)self, cls); |
| 1545 |
} |
| 1546 |
|
| 1547 |
PyDoc_STRVAR(_sre_SRE_Scanner_search__doc__, |
| 1548 |
"search($self, /)\n" |
| 1549 |
"--\n" |
| 1550 |
"\n"); |
| 1551 |
|
| 1552 |
#define _SRE_SRE_SCANNER_SEARCH_METHODDEF \ |
| 1553 |
{"search", _PyCFunction_CAST(_sre_SRE_Scanner_search), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _sre_SRE_Scanner_search__doc__}, |
| 1554 |
|
| 1555 |
static PyObject * |
| 1556 |
_sre_SRE_Scanner_search_impl(ScannerObject *self, PyTypeObject *cls); |
| 1557 |
|
| 1558 |
static PyObject * |
| 1559 |
_sre_SRE_Scanner_search(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 1560 |
{ |
| 1561 |
if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) { |
| 1562 |
PyErr_SetString(PyExc_TypeError, "search() takes no arguments"); |
| 1563 |
return NULL; |
| 1564 |
} |
| 1565 |
return _sre_SRE_Scanner_search_impl((ScannerObject *)self, cls); |
| 1566 |
} |
| 1567 |
|
| 1568 |
#ifndef _SRE_SRE_PATTERN__FAIL_AFTER_METHODDEF |
| 1569 |
#define _SRE_SRE_PATTERN__FAIL_AFTER_METHODDEF |
| 1570 |
#endif /* !defined(_SRE_SRE_PATTERN__FAIL_AFTER_METHODDEF) */ |
| 1571 |
/*[clinic end generated code: output=bbf42e1de3bdd3ae input=a9049054013a1b77]*/ |