mirror of
https://github.com/python/cpython.git
synced 2025-12-08 02:08:20 +00:00
GH-98363: Slicing isn't necessary. A size reduction will suffice. (GH-98538)
This commit is contained in:
parent
f7f55a5b9e
commit
5871e19942
1 changed files with 6 additions and 7 deletions
|
|
@ -167,23 +167,22 @@ batched_next(batchedobject *bo)
|
||||||
|
|
||||||
null_item:
|
null_item:
|
||||||
if (PyErr_Occurred()) {
|
if (PyErr_Occurred()) {
|
||||||
if (PyErr_ExceptionMatches(PyExc_StopIteration)) {
|
if (!PyErr_ExceptionMatches(PyExc_StopIteration)) {
|
||||||
PyErr_Clear();
|
/* Input raised an exception other than StopIteration */
|
||||||
} else {
|
|
||||||
/* input raised an exception other than StopIteration */
|
|
||||||
Py_CLEAR(bo->it);
|
Py_CLEAR(bo->it);
|
||||||
Py_DECREF(result);
|
Py_DECREF(result);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
PyErr_Clear();
|
||||||
}
|
}
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
Py_CLEAR(bo->it);
|
Py_CLEAR(bo->it);
|
||||||
Py_DECREF(result);
|
Py_DECREF(result);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
PyObject *short_list = PyList_GetSlice(result, 0, i);
|
/* Elements in result[i:] are still NULL */
|
||||||
Py_DECREF(result);
|
Py_SET_SIZE(result, i);
|
||||||
return short_list;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyTypeObject batched_type = {
|
static PyTypeObject batched_type = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue