diff options
author | Jesus Cea <jcea@jcea.es> | 2011-04-20 15:42:50 (GMT) |
---|---|---|
committer | Jesus Cea <jcea@jcea.es> | 2011-04-20 15:42:50 (GMT) |
commit | 6159ee3cf59b3fd8fcf9818c0a8071362d1ad7c2 (patch) | |
tree | b88b6a09bb17dadbfef3b400338da44ba881178e /Objects/unicodeobject.c | |
parent | 25458f155a285c60e71e4966bb1b1f6fdfaf7bb1 (diff) | |
parent | ac4515063c18157645d135bca8c4cf39542ccd6e (diff) | |
download | cpython-6159ee3cf59b3fd8fcf9818c0a8071362d1ad7c2.zip cpython-6159ee3cf59b3fd8fcf9818c0a8071362d1ad7c2.tar.gz cpython-6159ee3cf59b3fd8fcf9818c0a8071362d1ad7c2.tar.bz2 |
MERGE: startswith and endswith don't accept None as slice index. Patch by Torsten Becker. (closes #11828)
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index cbda725..ddf6f2e 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -7442,13 +7442,8 @@ unicode_count(PyUnicodeObject *self, PyObject *args) Py_ssize_t end = PY_SSIZE_T_MAX; PyObject *result; - if (!PyArg_ParseTuple(args, "O|O&O&:count", &substring, - _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) - return NULL; - - substring = (PyUnicodeObject *)PyUnicode_FromObject( - (PyObject *)substring); - if (substring == NULL) + if (!stringlib_parse_args_finds_unicode("count", args, &substring, + &start, &end)) return NULL; ADJUST_INDICES(start, end, self->length); @@ -7585,12 +7580,13 @@ Return -1 on failure."); static PyObject * unicode_find(PyUnicodeObject *self, PyObject *args) { - PyObject *substring; + PyUnicodeObject *substring; Py_ssize_t start; Py_ssize_t end; Py_ssize_t result; - if (!_ParseTupleFinds(args, &substring, &start, &end)) + if (!stringlib_parse_args_finds_unicode("find", args, &substring, + &start, &end)) return NULL; result = stringlib_find_slice( @@ -7647,11 +7643,12 @@ static PyObject * unicode_index(PyUnicodeObject *self, PyObject *args) { Py_ssize_t result; - PyObject *substring; + PyUnicodeObject *substring; Py_ssize_t start; Py_ssize_t end; - if (!_ParseTupleFinds(args, &substring, &start, &end)) + if (!stringlib_parse_args_finds_unicode("index", args, &substring, + &start, &end)) return NULL; result = stringlib_find_slice( @@ -8509,12 +8506,13 @@ Return -1 on failure."); static PyObject * unicode_rfind(PyUnicodeObject *self, PyObject *args) { - PyObject *substring; + PyUnicodeObject *substring; Py_ssize_t start; Py_ssize_t end; Py_ssize_t result; - if (!_ParseTupleFinds(args, &substring, &start, &end)) + if (!stringlib_parse_args_finds_unicode("rfind", args, &substring, + &start, &end)) return NULL; result = stringlib_rfind_slice( @@ -8536,12 +8534,13 @@ Like S.rfind() but raise ValueError when the substring is not found."); static PyObject * unicode_rindex(PyUnicodeObject *self, PyObject *args) { - PyObject *substring; + PyUnicodeObject *substring; Py_ssize_t start; Py_ssize_t end; Py_ssize_t result; - if (!_ParseTupleFinds(args, &substring, &start, &end)) + if (!stringlib_parse_args_finds_unicode("rindex", args, &substring, + &start, &end)) return NULL; result = stringlib_rfind_slice( @@ -9011,8 +9010,7 @@ unicode_startswith(PyUnicodeObject *self, Py_ssize_t end = PY_SSIZE_T_MAX; int result; - if (!PyArg_ParseTuple(args, "O|O&O&:startswith", &subobj, - _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) + if (!stringlib_parse_args_finds("startswith", args, &subobj, &start, &end)) return NULL; if (PyTuple_Check(subobj)) { Py_ssize_t i; @@ -9057,8 +9055,7 @@ unicode_endswith(PyUnicodeObject *self, Py_ssize_t end = PY_SSIZE_T_MAX; int result; - if (!PyArg_ParseTuple(args, "O|O&O&:endswith", &subobj, - _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) + if (!stringlib_parse_args_finds("endswith", args, &subobj, &start, &end)) return NULL; if (PyTuple_Check(subobj)) { Py_ssize_t i; |