Skip to content

Commit 118e9ec

Browse files
Copilotcsm10495
andcommitted
Remove unnecessary PY_SSIZE_T_MAX overflow check for slicelength_bound
Co-authored-by: csm10495 <5749838+csm10495@users.noreply.github.com> Agent-Logs-Url: https://github.com/csm10495/cpython/sessions/2a4b3921-dacb-4e10-8633-d2bf840cdc99
1 parent 07e15f5 commit 118e9ec

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

Objects/listobject.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3850,18 +3850,12 @@ list_ass_subscript_lock_held(PyObject *_self, PyObject *item, PyObject *value)
38503850
}
38513851
return -1;
38523852
}
3853-
Py_ssize_t alloc;
3854-
if (slicelength_bound >= PY_SSIZE_T_MAX) {
3855-
alloc = PY_SSIZE_T_MAX;
3856-
}
3857-
else {
3858-
alloc = slicelength_bound + 1;
3859-
if (alloc <= 0) {
3860-
/* Zero-length slice; still collect at least
3861-
1 item so the size check can detect a
3862-
non-empty iterable. */
3863-
alloc = 1;
3864-
}
3853+
Py_ssize_t alloc = slicelength_bound + 1;
3854+
if (alloc <= 0) {
3855+
/* Overflow or zero-length slice; still collect at
3856+
least 1 item so the size check can detect a
3857+
non-empty iterable. */
3858+
alloc = 1;
38653859
}
38663860
seq = PyList_New(alloc);
38673861
if (seq == NULL) {

0 commit comments

Comments
 (0)