diff options
| author | Serhiy Storchaka <storchaka@gmail.com> | 2017-04-08 08:48:57 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-04-08 08:48:57 (GMT) |
| commit | e41390aca51e4e3eb455cf3b70f5d656a2814db9 (patch) | |
| tree | e90f8b0b47ec38d5dc7871b4e5b0f944c46473a4 /Modules/arraymodule.c | |
| parent | 7f85947106aff5b1f166a57f644f987db4d38bf0 (diff) | |
| download | cpython-e41390aca51e4e3eb455cf3b70f5d656a2814db9.zip cpython-e41390aca51e4e3eb455cf3b70f5d656a2814db9.tar.gz cpython-e41390aca51e4e3eb455cf3b70f5d656a2814db9.tar.bz2 | |
bpo-27867: Expand the PySlice_GetIndicesEx macro. (#1023) (#1046)
(cherry picked from commit b879fe8)
Diffstat (limited to 'Modules/arraymodule.c')
| -rw-r--r-- | Modules/arraymodule.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 9819141..310ce7a 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -1701,10 +1701,11 @@ array_subscr(arrayobject* self, PyObject* item) arrayobject* ar; int itemsize = self->ob_descr->itemsize; - if (PySlice_GetIndicesEx((PySliceObject*)item, Py_SIZE(self), - &start, &stop, &step, &slicelength) < 0) { + if (_PySlice_Unpack((PySliceObject *)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); @@ -1772,11 +1773,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((PySliceObject *)item, - Py_SIZE(self), &start, &stop, - &step, &slicelength) < 0) { + if (_PySlice_Unpack((PySliceObject *)item, &start, &stop, &step) < 0) { return -1; } + slicelength = _PySlice_AdjustIndices(Py_SIZE(self), &start, &stop, + step); } else { PyErr_SetString(PyExc_TypeError, |
