summaryrefslogtreecommitdiffstats
path: root/Modules/_sre.c
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2001-10-22 06:01:56 (GMT)
committerFredrik Lundh <fredrik@pythonware.com>2001-10-22 06:01:56 (GMT)
commitf864aa8fd9afc1410dd7dc4d147c3bd8b7d5342a (patch)
tree95b14e0eaf17181939bc88f9d0d4d529ba560736 /Modules/_sre.c
parent5c66a26dee41853a9ce43b75965cc16b8e34aef0 (diff)
downloadcpython-f864aa8fd9afc1410dd7dc4d147c3bd8b7d5342a.zip
cpython-f864aa8fd9afc1410dd7dc4d147c3bd8b7d5342a.tar.gz
cpython-f864aa8fd9afc1410dd7dc4d147c3bd8b7d5342a.tar.bz2
sre.split should return the last segment, even if empty
(sorry, barry)
Diffstat (limited to 'Modules/_sre.c')
-rw-r--r--Modules/_sre.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/Modules/_sre.c b/Modules/_sre.c
index 5573046..73ffa70 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -2007,17 +2007,16 @@ pattern_split(PatternObject* self, PyObject* args, PyObject* kw)
}
- /* get segment following last match */
- i = STATE_OFFSET(&state, last);
- if (i < state.endpos) {
- item = PySequence_GetSlice(string, i, state.endpos);
- if (!item)
- goto error;
- status = PyList_Append(list, item);
- Py_DECREF(item);
- if (status < 0)
- goto error;
- }
+ /* get segment following last match (even if empty) */
+ item = PySequence_GetSlice(
+ string, STATE_OFFSET(&state, last), state.endpos
+ );
+ if (!item)
+ goto error;
+ status = PyList_Append(list, item);
+ Py_DECREF(item);
+ if (status < 0)
+ goto error;
state_fini(&state);
return list;