Skip to content

Commit

Permalink
Fix reverse step bugs
Browse files Browse the repository at this point in the history
Fixes google#36
  • Loading branch information
jayvdb committed Sep 24, 2020
1 parent 1bef76e commit f56846a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sre_yield/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ def slice_indices(slice_obj, size):
start = size - 1
else:
start = _adjust_index(start, size, raise_index_error=False)
if step < 0:
start = min(start, size - 1)

if stop is None:
if step > 0:
Expand All @@ -98,6 +100,8 @@ def slice_indices(slice_obj, size):
stop = -1
else:
stop = _adjust_index(stop, size, raise_index_error=False)
if step < 0:
stop = max(stop, -1)

return (start, stop, step)

Expand Down

0 comments on commit f56846a

Please sign in to comment.