def normalize_slice(slice_obj, length):
if isinstance(slice_obj, slice):<EOL><INDENT>start, stop, step = slice_obj.start, slice_obj.stop, slice_obj.step<EOL>if start is None:<EOL><INDENT>start = <NUM_LIT:0><EOL><DEDENT>if stop is None:<EOL><INDENT>stop = length<EOL><DEDENT>if step is None:<EOL><INDENT>step = <NUM_LIT:1><EOL><DEDENT>if start < <NUM_LIT:0>:<EOL><INDENT>start += length<EOL><DEDENT>if stop < <NUM_LIT:0>:<EOL><INDENT>stop += length<EOL><DEDENT><DEDENT>elif isinstance(slice_obj, int):<EOL><INDENT>start = slice_obj<EOL>if start < <NUM_LIT:0>:<EOL><INDENT>start += length<EOL><DEDENT>stop = start + <NUM_LIT:1><EOL>step = <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>raise TypeError<EOL><DEDENT>if (<NUM_LIT:0> <= start <= length) and (<NUM_LIT:0> <= stop <= length):<EOL><INDENT>return start, stop, step<EOL><DEDENT>raise IndexError<EOL>
Given a slice object, return appropriate values for use in the range function

:param slice_obj: The slice object or integer provided in the `[]` notation
:param length: For negative indexing we need to know the max length of the object.