summaryrefslogtreecommitdiffstats
path: root/Objects/tupleobject.c
diff options
context:
space:
mode:
authorPetri Lehtinen <petri@digip.org>2011-11-05 21:23:17 (GMT)
committerPetri Lehtinen <petri@digip.org>2011-11-05 21:25:34 (GMT)
commit8e9f6c42513e89cc8ca71e270aeb4a670c431715 (patch)
tree42493db753826247466ba983621fc6679546dca7 /Objects/tupleobject.c
parent68fb89fdb7f48a354f1fcb95581e7d605d5d53c0 (diff)
parentc2f0a46111dfc9958d1c0428f688b8f625888c88 (diff)
downloadcpython-8e9f6c42513e89cc8ca71e270aeb4a670c431715.zip
cpython-8e9f6c42513e89cc8ca71e270aeb4a670c431715.tar.gz
cpython-8e9f6c42513e89cc8ca71e270aeb4a670c431715.tar.bz2
Accept None as start and stop parameters for list.index() and tuple.index().
Closes #13340.
Diffstat (limited to 'Objects/tupleobject.c')
-rw-r--r--Objects/tupleobject.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index 54a580d..e311fcc 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -484,12 +484,19 @@ static PyObject *
tupleindex(PyTupleObject *self, PyObject *args)
{
Py_ssize_t i, start=0, stop=Py_SIZE(self);
- PyObject *v;
+ PyObject *v, *start_obj = NULL, *stop_obj = NULL;
- if (!PyArg_ParseTuple(args, "O|O&O&:index", &v,
- _PyEval_SliceIndex, &start,
- _PyEval_SliceIndex, &stop))
+ if (!PyArg_ParseTuple(args, "O|OO:index", &v, &start_obj, &stop_obj))
return NULL;
+
+ if (start_obj != Py_None)
+ if (!_PyEval_SliceIndex(start_obj, &start))
+ return NULL;
+
+ if (stop_obj != Py_None)
+ if (!_PyEval_SliceIndex(stop_obj, &stop))
+ return NULL;
+
if (start < 0) {
start += Py_SIZE(self);
if (start < 0)