summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorJesus Cea <jcea@jcea.es>2011-04-20 15:09:23 (GMT)
committerJesus Cea <jcea@jcea.es>2011-04-20 15:09:23 (GMT)
commitac4515063c18157645d135bca8c4cf39542ccd6e (patch)
treea9f65e370ab063ec2c611215da1525fdf247c035 /Objects/unicodeobject.c
parentd07eaf177c7d43a2479c1eb1fbab55e26e3822fa (diff)
downloadcpython-ac4515063c18157645d135bca8c4cf39542ccd6e.zip
cpython-ac4515063c18157645d135bca8c4cf39542ccd6e.tar.gz
cpython-ac4515063c18157645d135bca8c4cf39542ccd6e.tar.bz2
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.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 6bffaea..877640d 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -7150,13 +7150,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;
FIX_START_END(self);
@@ -7306,12 +7301,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(
@@ -7368,11 +7364,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(
@@ -8230,12 +8227,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(
@@ -8257,12 +8255,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(
@@ -8725,8 +8724,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;
@@ -8771,8 +8769,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;