summaryrefslogtreecommitdiffstats
path: root/Objects/sliceobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/sliceobject.c')
-rw-r--r--Objects/sliceobject.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c
index 075418e..8748fed 100644
--- a/Objects/sliceobject.c
+++ b/Objects/sliceobject.c
@@ -169,8 +169,9 @@ PySlice_GetIndicesEx(PySliceObject *r, Py_ssize_t length,
else {
if (!_PyEval_SliceIndex(r->stop, stop)) return -1;
if (*stop < 0) *stop += length;
- if (*stop < 0) *stop = -1;
- if (*stop > length) *stop = length;
+ if (*stop < 0) *stop = (*step < 0) ? -1 : 0;
+ if (*stop >= length)
+ *stop = (*step < 0) ? length - 1 : length;
}
if ((*step < 0 && *stop >= *start)