summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2000-09-02 16:36:57 (GMT)
committerFredrik Lundh <fredrik@pythonware.com>2000-09-02 16:36:57 (GMT)
commit510c97ba2f573bb5336681126ea6aad45a928a52 (patch)
treeaae70f97d65707e07fa04440e94044a7c3f950c6 /Modules
parentff07f8c7eaab3f0000c30921545c01429977aeff (diff)
downloadcpython-510c97ba2f573bb5336681126ea6aad45a928a52.zip
cpython-510c97ba2f573bb5336681126ea6aad45a928a52.tar.gz
cpython-510c97ba2f573bb5336681126ea6aad45a928a52.tar.bz2
return -1 for undefined groups (as implemented in 1.5.2) instead of
None (as documented) from start/end/span. closes bug #113254
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_sre.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/Modules/_sre.c b/Modules/_sre.c
index 61ee694..dc6478b 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -17,6 +17,7 @@
* 00-08-07 fl use PyOS_CheckStack() if available
* 00-08-08 fl changed findall to return empty strings instead of None
* 00-08-27 fl properly propagate memory errors
+ * 00-09-02 fl return -1 instead of None for start/end/span
*
* Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved.
*
@@ -1983,11 +1984,7 @@ match_start(MatchObject* self, PyObject* args)
return NULL;
}
- if (self->mark[index*2] < 0) {
- Py_INCREF(Py_None);
- return Py_None;
- }
-
+ /* mark is -1 if group is undefined */
return Py_BuildValue("i", self->mark[index*2]);
}
@@ -2010,11 +2007,7 @@ match_end(MatchObject* self, PyObject* args)
return NULL;
}
- if (self->mark[index*2] < 0) {
- Py_INCREF(Py_None);
- return Py_None;
- }
-
+ /* mark is -1 if group is undefined */
return Py_BuildValue("i", self->mark[index*2+1]);
}
@@ -2064,12 +2057,7 @@ match_span(MatchObject* self, PyObject* args)
return NULL;
}
- if (self->mark[index*2] < 0) {
- Py_INCREF(Py_None);
- Py_INCREF(Py_None);
- return Py_BuildValue("OO", Py_None, Py_None);
- }
-
+ /* marks are -1 if group is undefined */
return _pair(self->mark[index*2], self->mark[index*2+1]);
}