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/bytesobject.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/bytesobject.c')
-rw-r--r-- | Objects/bytesobject.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index fcc499e..9751201 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -1244,19 +1244,9 @@ bytes_find_internal(PyBytesObject *self, PyObject *args, int dir) const char *sub; Py_ssize_t sub_len; Py_ssize_t start=0, end=PY_SSIZE_T_MAX; - PyObject *obj_start=Py_None, *obj_end=Py_None; - if (!PyArg_ParseTuple(args, "O|OO:find/rfind/index/rindex", &subobj, - &obj_start, &obj_end)) - return -2; - /* To support None in "start" and "end" arguments, meaning - the same as if they were not passed. - */ - if (obj_start != Py_None) - if (!_PyEval_SliceIndex(obj_start, &start)) - return -2; - if (obj_end != Py_None) - if (!_PyEval_SliceIndex(obj_end, &end)) + if (!stringlib_parse_args_finds("find/rfind/index/rindex", + args, &subobj, &start, &end)) return -2; if (PyBytes_Check(subobj)) { @@ -1503,8 +1493,7 @@ bytes_count(PyBytesObject *self, PyObject *args) Py_ssize_t sub_len; Py_ssize_t start = 0, end = PY_SSIZE_T_MAX; - if (!PyArg_ParseTuple(args, "O|O&O&:count", &sub_obj, - _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) + if (!stringlib_parse_args_finds("count", args, &sub_obj, &start, &end)) return NULL; if (PyBytes_Check(sub_obj)) { @@ -2222,8 +2211,7 @@ bytes_startswith(PyBytesObject *self, PyObject *args) PyObject *subobj; 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; @@ -2263,8 +2251,7 @@ bytes_endswith(PyBytesObject *self, PyObject *args) PyObject *subobj; 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; |