8000 bpo-30074: Fix compile warnings of _PySlice_Unpack and convert missed by serhiy-storchaka · Pull Request #1154 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-30074: Fix compile warnings of _PySlice_Unpack and convert missed #1154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Modules/_ctypes/_ctypes.c
Original file line number Diff line number Diff line change 8000
Expand Up @@ -4434,9 +4434,7 @@ Array_subscript(PyObject *_self, PyObject *item)
PyObject *np;
Py_ssize_t start, stop, step, slicelen, cur, i;

if (PySlice_GetIndicesEx((PySliceObject *)item,
self->b_length, &start, &stop,
&step, &slicelen) < 0) {
if (_PySlice_Unpack(item, &start, &stop, &step) < 0) {
return NULL;
}

Expand All @@ -4447,6 +4445,7 @@ Array_subscript(PyObject *_self, PyObject *item)
assert(itemdict); /* proto is the item type of the array, a
ctypes type, so this cannot be NULL */

slicelen = _PySlice_AdjustIndices(self->b_length, &start, &stop, step);
if (itemdict->getfunc == _ctypes_get_fielddesc("c")->getfunc) {
char *ptr = (char *)self->b_ptr;
char *dest;
Expand Down Expand Up @@ -4613,7 +4612,7 @@ Array_ass_subscript(PyObject *_self, PyObject *item, PyObject *value)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelen, otherlen, i, cur;

if (_PySlice_Unpack((PySliceObject *)item, &start, &stop, &step) < 0) {
if (_PySlice_Unpack(item, &start, &stop, &step) < 0) {
return -1;
}
slicelen = _PySlice_AdjustIndices(self->b_length, &start, &stop, step);
Expand Down
4 changes: 2 additions & 2 deletions Modules/_elementtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,7 @@ element_subscr(PyObject* self_, PyObject* item)
if (!self->extra)
return PyList_New(0);

if (_PySlice_Unpack((PySliceObject *)item, &start, &stop, &step) < 0) {
if (_PySlice_Unpack(item, &start, &stop, &step) < 0) {
return NULL;
}
slicelen = _PySlice_AdjustIndices(self->extra->length, &start, &stop,
Expand Down Expand Up @@ -1393,7 +1393,7 @@ element_ass_subscr(PyObject* self_, PyObject* item, PyObject* value)
if (!self->extra)
element_new_extra(self, NULL);

if (_PySlice_Unpack((PySliceObject *)item, &start, &stop, &step) < 0) {
if (_PySlice_Unpack(item, &start, &stop, &step) < 0) {
return -1;
}
slicelen = _PySlice_AdjustIndices(self->extra->length, &start, &stop,
Expand Down
4 changes: 2 additions & 2 deletions Modules/arraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1701,7 +1701,7 @@ array_subscr(arrayobject* self, PyObject* item)
arrayobject* ar;
int itemsize = self->ob_descr->itemsize;

if (_PySlice_Unpack((PySliceObject *)item, &start, &stop, &step) < 0) {
if (_PySlice_Unpack(item, &start, &stop, &step) < 0) {
return NULL;
}
slicelength = _PySlice_AdjustIndices(Py_SIZE(self), &start, &stop,
Expand Down Expand Up @@ -1773,7 +1773,7 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
return (*self->ob_descr->setitem)(self, i, value);
}
else if (PySlice_Check(item)) {
if (_PySlice_Unpack((PySliceObject *)item, &start, &stop, &step) < 0) {
if (_PySlice_Unpack(item, &start, &stop, &step) < 0) {
return -1;
}
slicelength = _PySlice_AdjustIndices(Py_SIZE(self), &start, &stop,
Expand Down
4 changes: 2 additions & 2 deletions Modules/mmapmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ mmap_subscript(mmap_object *self, PyObject *item)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelen;

if (_PySlice_Unpack((PySliceObject *)item, &start, &stop, &step) < 0) {
if (_PySlice_Unpack(item, &start, &stop, &step) < 0) {
return NULL;
}
slicelen = _PySlice_AdjustIndices(self->size, &start, &stop, step);
Expand Down Expand Up @@ -939,7 +939,7 @@ mmap_ass_subscript(mmap_object *self, PyObject *item, PyObject *value)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelen;

if (_PySlice_Unpack((PySliceObject *)item, &start, &stop, &step) < 0) {
if (_PySlice_Unpack(item, &start, &stop, &step) < 0) {
return -1;
}
slicelen = _PySlice_AdjustIndices(self->size, &start, &stop, step);
Expand Down
4 changes: 2 additions & 2 deletions Objects/bytearrayobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ bytearray_subscript(PyByteArrayObject *self, PyObject *index)
}
else if (PySlice_Check(index)) {
Py_ssize_t start, stop, step, slicelength, cur, i;
if (_PySlice_Unpack((PySliceObject *)index, &start, &stop, &step) < 0) {
if (_PySlice_Unpack(index, &start, &stop, &step) < 0) {
return NULL;
}
slicelength = _PySlice_AdjustIndices(PyByteArray_GET_SIZE(self),
Expand Down Expand Up @@ -619,7 +619,7 @@ bytearray_ass_subscript(PyByteArrayObject *self, PyObject *index, PyObject *valu
}
}
else if (PySlice_Check(index)) {
if (_PySlice_Unpack((PySliceObject *)index, &start, &stop, &step) < 0) {
if (_PySlice_Unpack(index, &start, &stop, &step) < 0) {
return -1;
}
slicelen = _PySlice_AdjustIndices(PyByteArray_GET_SIZE(self), &start,
Expand Down
4 changes: 2 additions & 2 deletions Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2562,7 +2562,7 @@ list_subscript(PyListObject* self, PyObject* item)
PyObject* it;
PyObject **src, **dest;

if (_PySlice_Unpack((PySliceObject *)item, &start, &stop, &step) < 0) {
if (_PySlice_Unpack(item, &start, &stop, &step) < 0) {
return NULL;
}
slicelength = _PySlice_AdjustIndices(Py_SIZE(self), &start, &stop,
Expand Down Expand Up @@ -2612,7 +2612,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;

if (_PySlice_Unpack((PySliceObject *)item, &start, &stop, &step) < 0) {
if (_PySlice_Unpack(item, &start, &stop, &step) < 0) {
return -1;
}
slicelength = _PySlice_AdjustIndices(Py_SIZE(self), &start, &stop,
Expand Down
4 changes: 2 additions & 2 deletions Objects/memoryobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ memory_subscript(PyMemoryViewObject *self, PyObject *key)
else if (PySlice_Check(key)) {
Py_ssize_t start, stop, step, slicelength;

if (_PySlice_Unpack((PySliceObject *)key, &start, &stop, &step) < 0) {
if (_PySlice_Unpack(key, &start, &stop, &step) < 0) {
return NULL;
}
slicelength = _PySlice_AdjustIndices(get_shape0(view), &start, &stop,
Expand Down Expand Up @@ -663,7 +663,7 @@ memory_ass_sub(PyMemoryViewObject *self, PyObject *key, PyObject *value)
else if (PySlice_Check(key)) {
Py_ssize_t stop, step;

if (_PySlice_Unpack((PySliceObject *)key, &start, &stop, &step) < 0) {
if (_PySlice_Unpack(key, &start, &stop, &step) < 0) {
return -1;
}
len = _PySlice_AdjustIndices(get_shape0(view), &start, &stop, step);
Expand Down
6 changes: 3 additions & 3 deletions Objects/sliceobject.c
F438
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,18 @@ static PyMemberDef slice_members[] = {
static PyObject*
slice_indices(PySliceObject* self, PyObject* len)
{
Py_ssize_t ilen, start, stop, step, slicelength;
Py_ssize_t ilen, start, stop, step;

ilen = PyNumber_AsSsize_t(len, PyExc_OverflowError);

if (ilen == -1 && PyErr_Occurred()) {
return NULL;
}

if (_PySlice_Unpack(self, &start, &stop, &step) < 0) {
if (_PySlice_Unpack((PyObject *)self, &start, &stop, &step) < 0) {
return NULL;
}
slicelength = _PySlice_AdjustIndices(ilen, &start, &stop, step);
_PySlice_AdjustIndices(ilen, &start, &stop, step);

return Py_BuildValue("(nnn)", start, stop, step);
}
Expand Down
2 changes: 1 addition & 1 deletion Objects/stringobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ string_subscript(PyStringObject* self, PyObject* item)
char* result_buf;
PyObject* result;

if (_PySlice_Unpack((PySliceObject *)item, &start, &stop, &step) < 0) {
if (_PySlice_Unpack(item, &start, &stop, &step) < 0) {
return NULL;
}
slicelength = _PySlice_AdjustIndices(PyString_GET_SIZE(self), &start,
Expand Down
2 changes: 1 addition & 1 deletion Objects/structseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ structseq_subscript(PyStructSequence *self, PyObject *item)
Py_ssize_t start, stop, step, slicelen, cur, i;
PyObject *result;

if (_PySlice_Unpack((PySliceObject *)item, &start, &stop, &step) < 0) {
if (_PySlice_Unpack(item, &start, &stop, &step) < 0) {
return NULL;
}
slicelen = _PySlice_AdjustIndices(VISIBLE_SIZE(self), &start, &stop,
Expand Down
2 changes: 1 addition & 1 deletion Objects/tupleobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ tuplesubscript(PyTupleObject* self, PyObject* item)
PyObject* it;
PyObject **src, **dest;

if (_PySlice_Unpack((PySliceObject *)item, &start, &stop, &step) < 0) {
if (_PySlice_Unpack(item, &start, &stop, &step) < 0) {
return NULL;
}
slicelength = _PySlice_AdjustIndices(PyTuple_GET_SIZE(self), &start,
Expand Down
2 changes: 1 addition & 1 deletion Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -8008,7 +8008,7 @@ unicode_subscript(PyUnicodeObject* self, PyObject* item)
Py_UNICODE* result_buf;
PyObject* result;

if (_PySlice_Unpack((PySliceObject *)item, &start, &stop, &step) < 0) {
if (_PySlice_Unpack(item, &start, &stop, &step) < 0) {
return NULL;
}
slicelength = _PySlice_AdjustIndices(PyUnicode_GET_SIZE(self), &start,
Expand Down
0