def convert_slice_nones_to_ints(slice_item, target_length):
    """
    Converts None types within a slice to the appropriate ints based on object
    to be sliced.

    The one case where a None is left in the slice object is when the step is negative and
    the stop parameter is None, since this scenario cannot be represented with an int stop
    parameter.

    Parameters
    ----------
    slice_item: `slice`
       Slice for which Nones should be converted.

    target_length: `int`
        Length of object to which slice will be applied.

    Returns
    -------
    new_slice: `slice`
        Slice with Nones replaced with ints.
    """
    if slice_item.step is None:
        step = 1
    else:
        step = slice_item.step
    start = slice_item.start
    stop = slice_item.stop
    if step < 0:
        if slice_item.start is None:
            start = int(target_length)
        stop = slice_item.stop
    else:
        if not slice_item.start:
            start = 0
        if not slice_item.stop:
            stop = int(target_length)
    return slice(start, stop, step)
