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
ae0915e42d
commit
fa25f16a44
11 changed files with 47 additions and 45 deletions
|
@ -427,11 +427,11 @@ bytearray_subscript(PyByteArrayObject *self, PyObject *index)
|
|||
}
|
||||
else if (PySlice_Check(index)) {
|
||||
Py_ssize_t start, stop, step, slicelength, cur, i;
|
||||
if (PySlice_GetIndicesEx(index,
|
||||
PyByteArray_GET_SIZE(self),
|
||||
&start, &stop, &step, &slicelength) < 0) {
|
||||
if (PySlice_Unpack(index, &start, &stop, &step) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
slicelength = PySlice_AdjustIndices(PyByteArray_GET_SIZE(self),
|
||||
&start, &stop, step);
|
||||
|
||||
if (slicelength <= 0)
|
||||
return PyByteArray_FromStringAndSize("", 0);
|
||||
|
@ -657,11 +657,11 @@ bytearray_ass_subscript(PyByteArrayObject *self, PyObject *index, PyObject *valu
|
|||
}
|
||||
}
|
||||
else if (PySlice_Check(index)) {
|
||||
if (PySlice_GetIndicesEx(index,
|
||||
PyByteArray_GET_SIZE(self),
|
||||
&start, &stop, &step, &slicelen) < 0) {
|
||||
if (PySlice_Unpack(index, &start, &stop, &step) < 0) {
|
||||
return -1;
|
||||
}
|
||||
slicelen = PySlice_AdjustIndices(PyByteArray_GET_SIZE(self), &start,
|
||||
&stop, step);
|
||||
}
|
||||
else {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue