Skip to content

Commit

Permalink
reformat_slice: Set step of empty slices to 1.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakirkham committed Dec 5, 2016
1 parent 7e36250 commit e5fd4cb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kenjutsu/kenjutsu.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,17 @@ def reformat_slice(a_slice, a_length=None):
# Catch some known empty slices.
if stop_i and (start == stop):
start = stop = 0
step = 1
elif (step > 0) and (stop == 0):
start = stop = 0
step = 1
elif stop_i and (start >= 0) and (stop >= 0):
if (step > 0) and (start > stop):
start = stop = 0
step = 1
elif (step < 0) and (start < stop):
start = stop = 0
step = 1

new_slice = slice(start, stop, step)

Expand Down

0 comments on commit e5fd4cb

Please sign in to comment.