Issue #29195: Removed support of deprecated undocumented keyword arguments
in methods of regular expression objects.
This commit is contained in:
parent
8cbc51ab3d
commit
b37f3f6e6b
|
@ -212,6 +212,9 @@ Core and Builtins
|
|||
Library
|
||||
-------
|
||||
|
||||
- Issue #29195: Removed support of deprecated undocumented keyword arguments
|
||||
in methods of regular expression objects.
|
||||
|
||||
- Issue #28969: Fixed race condition in C implementation of functools.lru_cache.
|
||||
KeyError could be raised when cached function with full cache was
|
||||
simultaneously called from differen threads with the same uncached arguments.
|
||||
|
|
|
@ -551,55 +551,25 @@ sre_search(SRE_STATE* state, SRE_CODE* pattern)
|
|||
return sre_ucs4_search(state, pattern);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
fix_string_param(PyObject *string, PyObject *string2, const char *oldname)
|
||||
{
|
||||
if (string2 != NULL) {
|
||||
if (string != NULL) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"Argument given by name ('%s') and position (1)",
|
||||
oldname);
|
||||
return NULL;
|
||||
}
|
||||
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
|
||||
"The '%s' keyword parameter name is deprecated. "
|
||||
"Use 'string' instead.", oldname) < 0)
|
||||
return NULL;
|
||||
return string2;
|
||||
}
|
||||
if (string == NULL) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"Required argument 'string' (pos 1) not found");
|
||||
return NULL;
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_sre.SRE_Pattern.match
|
||||
|
||||
string: object = NULL
|
||||
string: object
|
||||
pos: Py_ssize_t = 0
|
||||
endpos: Py_ssize_t(c_default="PY_SSIZE_T_MAX") = sys.maxsize
|
||||
*
|
||||
pattern: object = NULL
|
||||
|
||||
Matches zero or more characters at the beginning of the string.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_sre_SRE_Pattern_match_impl(PatternObject *self, PyObject *string,
|
||||
Py_ssize_t pos, Py_ssize_t endpos,
|
||||
PyObject *pattern)
|
||||
/*[clinic end generated code: output=74b4b1da3bb2d84e input=3d079aa99979b81d]*/
|
||||
Py_ssize_t pos, Py_ssize_t endpos)
|
||||
/*[clinic end generated code: output=ea2d838888510661 input=a2ba191647abebe5]*/
|
||||
{
|
||||
SRE_STATE state;
|
||||
Py_ssize_t status;
|
||||
PyObject *match;
|
||||
|
||||
string = fix_string_param(string, pattern, "pattern");
|
||||
if (!string)
|
||||
return NULL;
|
||||
if (!state_init(&state, (PatternObject *)self, string, pos, endpos))
|
||||
return NULL;
|
||||
|
||||
|
@ -623,29 +593,22 @@ _sre_SRE_Pattern_match_impl(PatternObject *self, PyObject *string,
|
|||
/*[clinic input]
|
||||
_sre.SRE_Pattern.fullmatch
|
||||
|
||||
string: object = NULL
|
||||
string: object
|
||||
pos: Py_ssize_t = 0
|
||||
endpos: Py_ssize_t(c_default="PY_SSIZE_T_MAX") = sys.maxsize
|
||||
*
|
||||
pattern: object = NULL
|
||||
|
||||
Matches against all of the string
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_sre_SRE_Pattern_fullmatch_impl(PatternObject *self, PyObject *string,
|
||||
Py_ssize_t pos, Py_ssize_t endpos,
|
||||
PyObject *pattern)
|
||||
/*[clinic end generated code: output=1c98bc5da744ea94 input=d4228606cc12580f]*/
|
||||
Py_ssize_t pos, Py_ssize_t endpos)
|
||||
/*[clinic end generated code: output=5833c47782a35f4a input=a6f640614aaefceb]*/
|
||||
{
|
||||
SRE_STATE state;
|
||||
Py_ssize_t status;
|
||||
PyObject *match;
|
||||
|
||||
string = fix_string_param(string, pattern, "pattern");
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
||||
if (!state_init(&state, self, string, pos, endpos))
|
||||
return NULL;
|
||||
|
||||
|
@ -669,11 +632,9 @@ _sre_SRE_Pattern_fullmatch_impl(PatternObject *self, PyObject *string,
|
|||
/*[clinic input]
|
||||
_sre.SRE_Pattern.search
|
||||
|
||||
string: object = NULL
|
||||
string: object
|
||||
pos: Py_ssize_t = 0
|
||||
endpos: Py_ssize_t(c_default="PY_SSIZE_T_MAX") = sys.maxsize
|
||||
*
|
||||
pattern: object = NULL
|
||||
|
||||
Scan through string looking for a match, and return a corresponding match object instance.
|
||||
|
||||
|
@ -682,18 +643,13 @@ Return None if no position in the string matches.
|
|||
|
||||
static PyObject *
|
||||
_sre_SRE_Pattern_search_impl(PatternObject *self, PyObject *string,
|
||||
Py_ssize_t pos, Py_ssize_t endpos,
|
||||
PyObject *pattern)
|
||||
/*[clinic end generated code: output=3839394a18e5ea4f input=dab42720f4be3a4b]*/
|
||||
Py_ssize_t pos, Py_ssize_t endpos)
|
||||
/*[clinic end generated code: output=25f302a644e951e8 input=4ae5cb7dc38fed1b]*/
|
||||
{
|
||||
SRE_STATE state;
|
||||
Py_ssize_t status;
|
||||
PyObject *match;
|
||||
|
||||
string = fix_string_param(string, pattern, "pattern");
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
||||
if (!state_init(&state, self, string, pos, endpos))
|
||||
return NULL;
|
||||
|
||||
|
@ -762,30 +718,23 @@ deepcopy(PyObject** object, PyObject* memo)
|
|||
/*[clinic input]
|
||||
_sre.SRE_Pattern.findall
|
||||
|
||||
string: object = NULL
|
||||
string: object
|
||||
pos: Py_ssize_t = 0
|
||||
endpos: Py_ssize_t(c_default="PY_SSIZE_T_MAX") = sys.maxsize
|
||||
*
|
||||
source: object = NULL
|
||||
|
||||
Return a list of all non-overlapping matches of pattern in string.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_sre_SRE_Pattern_findall_impl(PatternObject *self, PyObject *string,
|
||||
Py_ssize_t pos, Py_ssize_t endpos,
|
||||
PyObject *source)
|
||||
/*[clinic end generated code: output=51295498b300639d input=df688355c056b9de]*/
|
||||
Py_ssize_t pos, Py_ssize_t endpos)
|
||||
/*[clinic end generated code: output=f4966baceea60aca input=5b6a4ee799741563]*/
|
||||
{
|
||||
SRE_STATE state;
|
||||
PyObject* list;
|
||||
Py_ssize_t status;
|
||||
Py_ssize_t i, b, e;
|
||||
|
||||
string = fix_string_param(string, source, "source");
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
||||
if (!state_init(&state, self, string, pos, endpos))
|
||||
return NULL;
|
||||
|
||||
|
@ -922,18 +871,16 @@ _sre_SRE_Pattern_scanner_impl(PatternObject *self, PyObject *string,
|
|||
/*[clinic input]
|
||||
_sre.SRE_Pattern.split
|
||||
|
||||
string: object = NULL
|
||||
string: object
|
||||
maxsplit: Py_ssize_t = 0
|
||||
*
|
||||
source: object = NULL
|
||||
|
||||
Split string by the occurrences of pattern.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_sre_SRE_Pattern_split_impl(PatternObject *self, PyObject *string,
|
||||
Py_ssize_t maxsplit, PyObject *source)
|
||||
/*[clinic end generated code: output=20bac2ff55b9f84c input=41e0b2e35e599d7b]*/
|
||||
Py_ssize_t maxsplit)
|
||||
/*[clinic end generated code: output=7ac66f381c45e0be input=1eeeb10dafc9947a]*/
|
||||
{
|
||||
SRE_STATE state;
|
||||
PyObject* list;
|
||||
|
@ -943,10 +890,6 @@ _sre_SRE_Pattern_split_impl(PatternObject *self, PyObject *string,
|
|||
Py_ssize_t i;
|
||||
void* last;
|
||||
|
||||
string = fix_string_param(string, source, "source");
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
||||
assert(self->codesize != 0);
|
||||
if (self->code[0] != SRE_OP_INFO || self->code[3] == 0) {
|
||||
if (self->code[0] == SRE_OP_INFO && self->code[4] == 0) {
|
||||
|
|
|
@ -63,7 +63,7 @@ exit:
|
|||
}
|
||||
|
||||
PyDoc_STRVAR(_sre_SRE_Pattern_match__doc__,
|
||||
"match($self, /, string=None, pos=0, endpos=sys.maxsize, *, pattern=None)\n"
|
||||
"match($self, /, string, pos=0, endpos=sys.maxsize)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Matches zero or more characters at the beginning of the string.");
|
||||
|
@ -73,33 +73,30 @@ PyDoc_STRVAR(_sre_SRE_Pattern_match__doc__,
|
|||
|
||||
static PyObject *
|
||||
_sre_SRE_Pattern_match_impl(PatternObject *self, PyObject *string,
|
||||
Py_ssize_t pos, Py_ssize_t endpos,
|
||||
PyObject *pattern);
|
||||
Py_ssize_t pos, Py_ssize_t endpos);
|
||||
|
||||
static PyObject *
|
||||
_sre_SRE_Pattern_match(PatternObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
static const char * const _keywords[] = {"string", "pos", "endpos", "pattern", NULL};
|
||||
static _PyArg_Parser _parser = {"|Onn$O:match", _keywords, 0};
|
||||
PyObject *string = NULL;
|
||||
static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
|
||||
static _PyArg_Parser _parser = {"O|nn:match", _keywords, 0};
|
||||
PyObject *string;
|
||||
Py_ssize_t pos = 0;
|
||||
Py_ssize_t endpos = PY_SSIZE_T_MAX;
|
||||
PyObject *pattern = NULL;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
|
||||
&string, &pos, &endpos, &pattern)) {
|
||||
&string, &pos, &endpos)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _sre_SRE_Pattern_match_impl(self, string, pos, endpos, pattern);
|
||||
return_value = _sre_SRE_Pattern_match_impl(self, string, pos, endpos);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_sre_SRE_Pattern_fullmatch__doc__,
|
||||
"fullmatch($self, /, string=None, pos=0, endpos=sys.maxsize, *,\n"
|
||||
" pattern=None)\n"
|
||||
"fullmatch($self, /, string, pos=0, endpos=sys.maxsize)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Matches against all of the string");
|
||||
|
@ -109,33 +106,30 @@ PyDoc_STRVAR(_sre_SRE_Pattern_fullmatch__doc__,
|
|||
|
||||
static PyObject *
|
||||
_sre_SRE_Pattern_fullmatch_impl(PatternObject *self, PyObject *string,
|
||||
Py_ssize_t pos, Py_ssize_t endpos,
|
||||
PyObject *pattern);
|
||||
Py_ssize_t pos, Py_ssize_t endpos);
|
||||
|
||||
static PyObject *
|
||||
_sre_SRE_Pattern_fullmatch(PatternObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
static const char * const _keywords[] = {"string", "pos", "endpos", "pattern", NULL};
|
||||
static _PyArg_Parser _parser = {"|Onn$O:fullmatch", _keywords, 0};
|
||||
PyObject *string = NULL;
|
||||
static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
|
||||
static _PyArg_Parser _parser = {"O|nn:fullmatch", _keywords, 0};
|
||||
PyObject *string;
|
||||
Py_ssize_t pos = 0;
|
||||
Py_ssize_t endpos = PY_SSIZE_T_MAX;
|
||||
PyObject *pattern = NULL;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
|
||||
&string, &pos, &endpos, &pattern)) {
|
||||
&string, &pos, &endpos)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _sre_SRE_Pattern_fullmatch_impl(self, string, pos, endpos, pattern);
|
||||
return_value = _sre_SRE_Pattern_fullmatch_impl(self, string, pos, endpos);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_sre_SRE_Pattern_search__doc__,
|
||||
"search($self, /, string=None, pos=0, endpos=sys.maxsize, *,\n"
|
||||
" pattern=None)\n"
|
||||
"search($self, /, string, pos=0, endpos=sys.maxsize)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Scan through string looking for a match, and return a corresponding match object instance.\n"
|
||||
|
@ -147,33 +141,30 @@ PyDoc_STRVAR(_sre_SRE_Pattern_search__doc__,
|
|||
|
||||
static PyObject *
|
||||
_sre_SRE_Pattern_search_impl(PatternObject *self, PyObject *string,
|
||||
Py_ssize_t pos, Py_ssize_t endpos,
|
||||
PyObject *pattern);
|
||||
Py_ssize_t pos, Py_ssize_t endpos);
|
||||
|
||||
static PyObject *
|
||||
_sre_SRE_Pattern_search(PatternObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
static const char * const _keywords[] = {"string", "pos", "endpos", "pattern", NULL};
|
||||
static _PyArg_Parser _parser = {"|Onn$O:search", _keywords, 0};
|
||||
PyObject *string = NULL;
|
||||
static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
|
||||
static _PyArg_Parser _parser = {"O|nn:search", _keywords, 0};
|
||||
PyObject *string;
|
||||
Py_ssize_t pos = 0;
|
||||
Py_ssize_t endpos = PY_SSIZE_T_MAX;
|
||||
PyObject *pattern = NULL;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
|
||||
&string, &pos, &endpos, &pattern)) {
|
||||
&string, &pos, &endpos)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _sre_SRE_Pattern_search_impl(self, string, pos, endpos, pattern);
|
||||
return_value = _sre_SRE_Pattern_search_impl(self, string, pos, endpos);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_sre_SRE_Pattern_findall__doc__,
|
||||
"findall($self, /, string=None, pos=0, endpos=sys.maxsize, *,\n"
|
||||
" source=None)\n"
|
||||
"findall($self, /, string, pos=0, endpos=sys.maxsize)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Return a list of all non-overlapping matches of pattern in string.");
|
||||
|
@ -183,25 +174,23 @@ PyDoc_STRVAR(_sre_SRE_Pattern_findall__doc__,
|
|||
|
||||
static PyObject *
|
||||
_sre_SRE_Pattern_findall_impl(PatternObject *self, PyObject *string,
|
||||
Py_ssize_t pos, Py_ssize_t endpos,
|
||||
PyObject *source);
|
||||
Py_ssize_t pos, Py_ssize_t endpos);
|
||||
|
||||
static PyObject *
|
||||
_sre_SRE_Pattern_findall(PatternObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
static const char * const _keywords[] = {"string", "pos", "endpos", "source", NULL};
|
||||
static _PyArg_Parser _parser = {"|Onn$O:findall", _keywords, 0};
|
||||
PyObject *string = NULL;
|
||||
static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
|
||||
static _PyArg_Parser _parser = {"O|nn:findall", _keywords, 0};
|
||||
PyObject *string;
|
||||
Py_ssize_t pos = 0;
|
||||
Py_ssize_t endpos = PY_SSIZE_T_MAX;
|
||||
PyObject *source = NULL;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
|
||||
&string, &pos, &endpos, &source)) {
|
||||
&string, &pos, &endpos)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _sre_SRE_Pattern_findall_impl(self, string, pos, endpos, source);
|
||||
return_value = _sre_SRE_Pattern_findall_impl(self, string, pos, endpos);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
|
@ -275,7 +264,7 @@ exit:
|
|||
}
|
||||
|
||||
PyDoc_STRVAR(_sre_SRE_Pattern_split__doc__,
|
||||
"split($self, /, string=None, maxsplit=0, *, source=None)\n"
|
||||
"split($self, /, string, maxsplit=0)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Split string by the occurrences of pattern.");
|
||||
|
@ -285,23 +274,22 @@ PyDoc_STRVAR(_sre_SRE_Pattern_split__doc__,
|
|||
|
||||
static PyObject *
|
||||
_sre_SRE_Pattern_split_impl(PatternObject *self, PyObject *string,
|
||||
Py_ssize_t maxsplit, PyObject *source);
|
||||
Py_ssize_t maxsplit);
|
||||
|
||||
static PyObject *
|
||||
_sre_SRE_Pattern_split(PatternObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
static const char * const _keywords[] = {"string", "maxsplit", "source", NULL};
|
||||
static _PyArg_Parser _parser = {"|On$O:split", _keywords, 0};
|
||||
PyObject *string = NULL;
|
||||
static const char * const _keywords[] = {"string", "maxsplit", NULL};
|
||||
static _PyArg_Parser _parser = {"O|n:split", _keywords, 0};
|
||||
PyObject *string;
|
||||
Py_ssize_t maxsplit = 0;
|
||||
PyObject *source = NULL;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
|
||||
&string, &maxsplit, &source)) {
|
||||
&string, &maxsplit)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = _sre_SRE_Pattern_split_impl(self, string, maxsplit, source);
|
||||
return_value = _sre_SRE_Pattern_split_impl(self, string, maxsplit);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
|
@ -728,4 +716,4 @@ _sre_SRE_Scanner_search(ScannerObject *self, PyObject *Py_UNUSED(ignored))
|
|||
{
|
||||
return _sre_SRE_Scanner_search_impl(self);
|
||||
}
|
||||
/*[clinic end generated code: output=b74b16d90f207358 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=586a4132fbe8c6a7 input=a9049054013a1b77]*/
|
||||
|
|
Loading…
Reference in New Issue