summaryrefslogtreecommitdiffstats
path: root/Objects/abstract.c
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-03-23 06:03:08 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-03-23 06:03:08 (GMT)
commitbadc086543e13be82958b8162d3fc5e5b65f283a (patch)
tree7c65ec8f0a8dc2482b55952a8f79b6ef877b71dd /Objects/abstract.c
parent90768424f8c48aa0d50642cb423b356adbf2293d (diff)
downloadcpython-badc086543e13be82958b8162d3fc5e5b65f283a.zip
cpython-badc086543e13be82958b8162d3fc5e5b65f283a.tar.gz
cpython-badc086543e13be82958b8162d3fc5e5b65f283a.tar.bz2
Stop duplicating code and handle slice indices consistently and correctly
wrt to ssize_t.
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r--Objects/abstract.c22
1 files changed, 2 insertions, 20 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 9d1aaf0..bee71d8 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -1247,24 +1247,6 @@ PySequence_GetItem(PyObject *s, Py_ssize_t i)
return type_error("unindexable object");
}
-static PyObject *
-sliceobj_from_ssizet_ssizet(Py_ssize_t i, Py_ssize_t j)
-{
- PyObject *start, *end, *slice;
- start = PyInt_FromSsize_t(i);
- if (!start)
- return NULL;
- end = PyInt_FromSsize_t(j);
- if (!end) {
- Py_DECREF(start);
- return NULL;
- }
- slice = PySlice_New(start, end, NULL);
- Py_DECREF(start);
- Py_DECREF(end);
- return slice;
-}
-
PyObject *
PySequence_GetSlice(PyObject *s, Py_ssize_t i1, Py_ssize_t i2)
{
@@ -1289,7 +1271,7 @@ PySequence_GetSlice(PyObject *s, Py_ssize_t i1, Py_ssize_t i2)
return m->sq_slice(s, i1, i2);
} else if ((mp = s->ob_type->tp_as_mapping) && mp->mp_subscript) {
PyObject *res;
- PyObject *slice = sliceobj_from_ssizet_ssizet(i1, i2);
+ PyObject *slice = _PySlice_FromIndices(i1, i2);
if (!slice)
return NULL;
res = mp->mp_subscript(s, slice);
@@ -1381,7 +1363,7 @@ PySequence_SetSlice(PyObject *s, Py_ssize_t i1, Py_ssize_t i2, PyObject *o)
return m->sq_ass_slice(s, i1, i2, o);
} else if ((mp = s->ob_type->tp_as_mapping) && mp->mp_ass_subscript) {
int res;
- PyObject *slice = sliceobj_from_ssizet_ssizet(i1, i2);
+ PyObject *slice = _PySlice_FromIndices(i1, i2);
if (!slice)
return -1;
res = mp->mp_ass_subscript(s, slice, o);