summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-11-22 22:04:39 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-11-22 22:04:39 (GMT)
commit726a57d45f8606ad5a33f7c6bbd1e8c2f8cfbdef (patch)
tree9ca6ccf2b5ee118ccf1fd0e7b47fcaf9f833cda7 /Modules
parente3d75c63cd100675f96cd5c152ccd021ba9e6ebb (diff)
downloadcpython-726a57d45f8606ad5a33f7c6bbd1e8c2f8cfbdef.zip
cpython-726a57d45f8606ad5a33f7c6bbd1e8c2f8cfbdef.tar.gz
cpython-726a57d45f8606ad5a33f7c6bbd1e8c2f8cfbdef.tar.bz2
Issue #28765: _sre.compile() now checks the type of groupindex and indexgroup
groupindex must a dictionary and indexgroup must be a tuple. Previously, indexgroup was a list. Use a tuple to reduce the memory usage.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_sre.c6
-rw-r--r--Modules/clinic/_sre.c.h6
-rw-r--r--Modules/sre.h4
3 files changed, 8 insertions, 8 deletions
diff --git a/Modules/_sre.c b/Modules/_sre.c
index 979e61f..6e14901 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -1438,8 +1438,8 @@ _sre.compile
flags: int
code: object(subclass_of='&PyList_Type')
groups: Py_ssize_t
- groupindex: object
- indexgroup: object
+ groupindex: object(subclass_of='&PyDict_Type')
+ indexgroup: object(subclass_of='&PyTuple_Type')
[clinic start generated code]*/
@@ -1447,7 +1447,7 @@ static PyObject *
_sre_compile_impl(PyObject *module, PyObject *pattern, int flags,
PyObject *code, Py_ssize_t groups, PyObject *groupindex,
PyObject *indexgroup)
-/*[clinic end generated code: output=ef9c2b3693776404 input=7d059ec8ae1edb85]*/
+/*[clinic end generated code: output=ef9c2b3693776404 input=0a68476dbbe5db30]*/
{
/* "compile" pattern descriptor to pattern object */
diff --git a/Modules/clinic/_sre.c.h b/Modules/clinic/_sre.c.h
index 0612005..2b76f0d 100644
--- a/Modules/clinic/_sre.c.h
+++ b/Modules/clinic/_sre.c.h
@@ -438,7 +438,7 @@ _sre_compile(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwna
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"pattern", "flags", "code", "groups", "groupindex", "indexgroup", NULL};
- static _PyArg_Parser _parser = {"OiO!nOO:compile", _keywords, 0};
+ static _PyArg_Parser _parser = {"OiO!nO!O!:compile", _keywords, 0};
PyObject *pattern;
int flags;
PyObject *code;
@@ -447,7 +447,7 @@ _sre_compile(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwna
PyObject *indexgroup;
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
- &pattern, &flags, &PyList_Type, &code, &groups, &groupindex, &indexgroup)) {
+ &pattern, &flags, &PyList_Type, &code, &groups, &PyDict_Type, &groupindex, &PyTuple_Type, &indexgroup)) {
goto exit;
}
return_value = _sre_compile_impl(module, pattern, flags, code, groups, groupindex, indexgroup);
@@ -728,4 +728,4 @@ _sre_SRE_Scanner_search(ScannerObject *self, PyObject *Py_UNUSED(ignored))
{
return _sre_SRE_Scanner_search_impl(self);
}
-/*[clinic end generated code: output=a4a246bca1963bc9 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=b74b16d90f207358 input=a9049054013a1b77]*/
diff --git a/Modules/sre.h b/Modules/sre.h
index b632165..9af5e40 100644
--- a/Modules/sre.h
+++ b/Modules/sre.h
@@ -27,8 +27,8 @@
typedef struct {
PyObject_VAR_HEAD
Py_ssize_t groups; /* must be first! */
- PyObject* groupindex;
- PyObject* indexgroup;
+ PyObject* groupindex; /* dict */
+ PyObject* indexgroup; /* tuple */
/* compatibility */
PyObject* pattern; /* pattern source (or None) */
int flags; /* flags used when compiling pattern source */