Expand the PySlice_GetIndicesEx macro. (#1023) (#1044)

(cherry picked from commit b879fe82e7)
This commit is contained in:
Serhiy Storchaka 2017-04-08 11:18:14 +03:00 committed by GitHub
parent d0d575a6db
commit c26b19d5c7
11 changed files with 47 additions and 45 deletions

View file

@ -806,10 +806,10 @@ mmap_subscript(mmap_object *self, PyObject *item)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelen;
if (PySlice_GetIndicesEx(item, self->size,
&start, &stop, &step, &slicelen) < 0) {
if (PySlice_Unpack(item, &start, &stop, &step) < 0) {
return NULL;
}
slicelen = PySlice_AdjustIndices(self->size, &start, &stop, step);
if (slicelen <= 0)
return PyBytes_FromStringAndSize("", 0);
@ -932,11 +932,10 @@ mmap_ass_subscript(mmap_object *self, PyObject *item, PyObject *value)
Py_ssize_t start, stop, step, slicelen;
Py_buffer vbuf;
if (PySlice_GetIndicesEx(item,
self->size, &start, &stop,
&step, &slicelen) < 0) {
if (PySlice_Unpack(item, &start, &stop, &step) < 0) {
return -1;
}
slicelen = PySlice_AdjustIndices(self->size, &start, &stop, step);
if (value == NULL) {
PyErr_SetString(PyExc_TypeError,
"mmap object doesn't support slice deletion");