Expand the PySlice_GetIndicesEx macro. (#1023)

This commit is contained in:
Serhiy Storchaka 2017-04-08 09:53:51 +03:00 committed by GitHub
parent 205e00c5cf
commit b879fe82e7
11 changed files with 47 additions and 45 deletions

View file

@ -2289,10 +2289,11 @@ array_subscr(arrayobject* self, PyObject* item)
arrayobject* ar;
int itemsize = self->ob_descr->itemsize;
if (PySlice_GetIndicesEx(item, Py_SIZE(self),
&start, &stop, &step, &slicelength) < 0) {
if (PySlice_Unpack(item, &start, &stop, &step) < 0) {
return NULL;
}
slicelength = PySlice_AdjustIndices(Py_SIZE(self), &start, &stop,
step);
if (slicelength <= 0) {
return newarrayobject(&Arraytype, 0, self->ob_descr);
@ -2360,11 +2361,11 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
return (*self->ob_descr->setitem)(self, i, value);
}
else if (PySlice_Check(item)) {
if (PySlice_GetIndicesEx(item,
Py_SIZE(self), &start, &stop,
&step, &slicelength) < 0) {
if (PySlice_Unpack(item, &start, &stop, &step) < 0) {
return -1;
}
slicelength = PySlice_AdjustIndices(Py_SIZE(self), &start, &stop,
step);
}
else {
PyErr_SetString(PyExc_TypeError,