mirror of
https://github.com/python/cpython.git
synced 2025-10-07 07:31:46 +00:00
(cherry picked from commit b879fe82e7
)
This commit is contained in:
parent
d0d575a6db
commit
c26b19d5c7
11 changed files with 47 additions and 45 deletions
|
@ -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");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue