summaryrefslogtreecommitdiffstats
path: root/Modules/_sre.c
diff options
context:
space:
mode:
authorSean Reifschneider <jafo@tummy.com>2012-03-13 00:22:38 (GMT)
committerSean Reifschneider <jafo@tummy.com>2012-03-13 00:22:38 (GMT)
commit7b3c975aafc40f09bfd0c39e42153c3a0d086fba (patch)
tree7c9214b99b13b7c65116b5c72135dfa9332beca0 /Modules/_sre.c
parent45e50de1f5eed5b2ee936e36dd297cd6a43c042d (diff)
downloadcpython-7b3c975aafc40f09bfd0c39e42153c3a0d086fba.zip
cpython-7b3c975aafc40f09bfd0c39e42153c3a0d086fba.tar.gz
cpython-7b3c975aafc40f09bfd0c39e42153c3a0d086fba.tar.bz2
closes #14259 re.finditer() now takes keyword arguments: pos, endpos.
Contrary to the documentation, finditer() did not take pos and endpos keyword arguments.
Diffstat (limited to 'Modules/_sre.c')
-rw-r--r--Modules/_sre.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/Modules/_sre.c b/Modules/_sre.c
index 9254480..cb1f791 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -1596,7 +1596,7 @@ SRE_SEARCH(SRE_STATE* state, SRE_CODE* pattern)
/* see sre.h for object declarations */
static PyObject*pattern_new_match(PatternObject*, SRE_STATE*, int);
-static PyObject*pattern_scanner(PatternObject*, PyObject*);
+static PyObject*pattern_scanner(PatternObject*, PyObject*, PyObject* kw);
static int
sre_literal_template(int charsize, char* ptr, Py_ssize_t len)
@@ -2132,13 +2132,13 @@ error:
#if PY_VERSION_HEX >= 0x02020000
static PyObject*
-pattern_finditer(PatternObject* pattern, PyObject* args)
+pattern_finditer(PatternObject* pattern, PyObject* args, PyObject* kw)
{
PyObject* scanner;
PyObject* search;
PyObject* iterator;
- scanner = pattern_scanner(pattern, args);
+ scanner = pattern_scanner(pattern, args, kw);
if (!scanner)
return NULL;
@@ -2576,10 +2576,10 @@ static PyMethodDef pattern_methods[] = {
{"findall", (PyCFunction) pattern_findall, METH_VARARGS|METH_KEYWORDS,
pattern_findall_doc},
#if PY_VERSION_HEX >= 0x02020000
- {"finditer", (PyCFunction) pattern_finditer, METH_VARARGS,
+ {"finditer", (PyCFunction) pattern_finditer, METH_VARARGS|METH_KEYWORDS,
pattern_finditer_doc},
#endif
- {"scanner", (PyCFunction) pattern_scanner, METH_VARARGS},
+ {"scanner", (PyCFunction) pattern_scanner, METH_VARARGS|METH_KEYWORDS},
{"__copy__", (PyCFunction) pattern_copy, METH_NOARGS},
{"__deepcopy__", (PyCFunction) pattern_deepcopy, METH_O},
{NULL, NULL}
@@ -3822,7 +3822,7 @@ static PyTypeObject Scanner_Type = {
};
static PyObject*
-pattern_scanner(PatternObject* pattern, PyObject* args)
+pattern_scanner(PatternObject* pattern, PyObject* args, PyObject* kw)
{
/* create search state object */
@@ -3831,7 +3831,9 @@ pattern_scanner(PatternObject* pattern, PyObject* args)
PyObject* string;
Py_ssize_t start = 0;
Py_ssize_t end = PY_SSIZE_T_MAX;
- if (!PyArg_ParseTuple(args, "O|nn:scanner", &string, &start, &end))
+ static char* kwlist[] = { "source", "pos", "endpos", NULL };
+ if (!PyArg_ParseTupleAndKeywords(args, kw, "O|nn:scanner", kwlist,
+ &string, &start, &end))
return NULL;
/* create scanner object */