mirror of
https://github.com/python/cpython.git
synced 2025-12-09 18:48:05 +00:00
Expand the PySlice_GetIndicesEx macro. (#1023)
This commit is contained in:
parent
205e00c5cf
commit
b879fe82e7
11 changed files with 47 additions and 45 deletions
|
|
@ -400,11 +400,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);
|
||||
|
|
@ -630,11 +630,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