Skip to content

Commit

Permalink
Merge pull request #27 from jakirkham/no_mut_arg_ref
Browse files Browse the repository at this point in the history
Maintain original arguments to reformat_slice
  • Loading branch information
jakirkham committed Dec 5, 2016
2 parents 65004d4 + 398ef3a commit 1c61584
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions kenjutsu/kenjutsu.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,20 @@ def reformat_slice(a_slice, a_length=None):
slice(2, 9, 1)
"""

if a_slice is Ellipsis:
a_slice = slice(None)
elif not isinstance(a_slice, slice):
new_slice = a_slice
if new_slice is Ellipsis:
new_slice = slice(None)
elif not isinstance(new_slice, slice):
raise ValueError(
"Expected a `slice` type. Instead got `%s`." % str(a_slice)
"Expected a `slice` type. Instead got `%s`." % str(new_slice)
)

if a_slice.step == 0:
if new_slice.step == 0:
raise ValueError("Slice cannot have a step size of `0`.")

start = a_slice.start
stop = a_slice.stop
step = a_slice.step
start = new_slice.start
stop = new_slice.stop
step = new_slice.step

# Fill unknown values.
if step is None:
Expand Down

0 comments on commit 1c61584

Please sign in to comment.