diff -r 41a99a2a7198 Objects/bufferobject.c --- a/Objects/bufferobject.c Sat Dec 24 10:41:37 2016 +0000 +++ b/Objects/bufferobject.c Thu Dec 29 13:43:32 2016 -0500 @@ -500,24 +500,29 @@ void *p; Py_ssize_t size; - if (!get_buf(self, &p, &size, ANY_BUFFER)) - return NULL; if (PyIndex_Check(item)) { Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError); if (i == -1 && PyErr_Occurred()) return NULL; - if (i < 0) + if (i < 0) { + if (!get_buf(self, &p, &size, ANY_BUFFER)) + return NULL; i += size; + } return buffer_item(self, i); } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength, cur, i; + size = buffer_length(self); if (PySlice_GetIndicesEx((PySliceObject*)item, size, &start, &stop, &step, &slicelength) < 0) { return NULL; } + if (!get_buf(self, &p, &size, ANY_BUFFER)) + return NULL; + if (slicelength <= 0) return PyString_FromStringAndSize("", 0); else if (step == 1)