summaryrefslogtreecommitdiffstats
path: root/Objects/classobject.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/classobject.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/classobject.c')
-rw-r--r--Objects/classobject.c27
1 files changed, 3 insertions, 24 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c
index f3e636a..ea95ec0 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -1128,27 +1128,6 @@ instance_item(PyInstanceObject *inst, Py_ssize_t i)
}
static PyObject *
-sliceobj_from_intint(Py_ssize_t i, Py_ssize_t j)
-{
- PyObject *start, *end, *res;
-
- start = PyInt_FromLong((long)i);
- if (!start)
- return NULL;
-
- end = PyInt_FromLong((long)j);
- if (!end) {
- Py_DECREF(start);
- return NULL;
- }
- res = PySlice_New(start, end, NULL);
- Py_DECREF(start);
- Py_DECREF(end);
- return res;
-}
-
-
-static PyObject *
instance_slice(PyInstanceObject *inst, Py_ssize_t i, Py_ssize_t j)
{
PyObject *func, *arg, *res;
@@ -1168,7 +1147,7 @@ instance_slice(PyInstanceObject *inst, Py_ssize_t i, Py_ssize_t j)
func = instance_getattr(inst, getitemstr);
if (func == NULL)
return NULL;
- arg = Py_BuildValue("(N)", sliceobj_from_intint(i, j));
+ arg = Py_BuildValue("(N)", _PySlice_FromIndices(i, j));
} else
arg = Py_BuildValue("(nn)", i, j);
@@ -1239,7 +1218,7 @@ instance_ass_slice(PyInstanceObject *inst, Py_ssize_t i, Py_ssize_t j, PyObject
return -1;
arg = Py_BuildValue("(N)",
- sliceobj_from_intint(i, j));
+ _PySlice_FromIndices(i, j));
} else
arg = Py_BuildValue("(nn)", i, j);
}
@@ -1260,7 +1239,7 @@ instance_ass_slice(PyInstanceObject *inst, Py_ssize_t i, Py_ssize_t j, PyObject
return -1;
arg = Py_BuildValue("(NO)",
- sliceobj_from_intint(i, j), value);
+ _PySlice_FromIndices(i, j), value);
} else
arg = Py_BuildValue("(nnO)", i, j, value);
}