def handle_index(l, index):
    """Handle index.

    If the index is negative, convert it. If the index is out of range, raise
    an IndexError.
    """
    # convert negative indices to positive ones
    index = fix_index(l, index)
    # check that the index is in range
    if index < 0 or index >= len(l):
        raise IndexError("list index out of range")
    return index
Handle index.

    If the index is negative, convert it. If the index is out of range, raise
    an IndexError.
    
numba/typed/listobject.py