Пример #1
0
def setitem__List_ANY_ANY(space, w_list, w_index, w_any):
    idx = get_list_index(space, w_index)
    try:
        w_list.wrappeditems[idx] = w_any
    except IndexError:
        raise OperationError(space.w_IndexError, space.wrap("list index out of range"))
    return space.w_None
Пример #2
0
def delitem__List_ANY(space, w_list, w_idx):
    idx = get_list_index(space, w_idx)
    try:
        del w_list.wrappeditems[idx]
    except IndexError:
        raise OperationError(space.w_IndexError, space.wrap("list deletion index out of range"))
    return space.w_None
Пример #3
0
def delitem__Bytearray_ANY(space, w_bytearray, w_idx):
    idx = get_list_index(space, w_idx)
    try:
        del w_bytearray.data[idx]
    except IndexError:
        raise OperationError(space.w_IndexError, space.wrap("bytearray deletion index out of range"))
    return space.w_None
Пример #4
0
def setitem__List_ANY_ANY(space, w_list, w_index, w_any):
    idx = get_list_index(space, w_index)
    try:
        w_list.wrappeditems[idx] = w_any
    except IndexError:
        raise OperationError(space.w_IndexError,
                             space.wrap("list index out of range"))
    return space.w_None
Пример #5
0
def delitem__List_ANY(space, w_list, w_idx):
    idx = get_list_index(space, w_idx)
    try:
        del w_list.wrappeditems[idx]
    except IndexError:
        raise OperationError(space.w_IndexError,
                             space.wrap("list deletion index out of range"))
    return space.w_None
Пример #6
0
def delitem__Bytearray_ANY(space, w_bytearray, w_idx):
    idx = get_list_index(space, w_idx)
    try:
        del w_bytearray.data[idx]
    except IndexError:
        raise OperationError(space.w_IndexError,
                             space.wrap("bytearray deletion index out of range"))
    return space.w_None
def delitem__ListMulti_ANY(space, w_list, w_idx):
    idx = get_list_index(space, w_idx)
    length = w_list.implementation.length()
    idx = _adjust_index(space, idx, length, "list deletion index out of range")
    if length == 1:
        w_list.implementation = space.fromcache(State).empty_impl
    else:
        w_list.implementation = w_list.implementation.i_delitem(idx)
    return space.w_None
Пример #8
0
def delitem__List_ANY(space, w_list, w_idx):
    idx = get_list_index(space, w_idx)
    if idx < 0:
        idx += w_list.length()
    try:
        w_list.pop(idx)
    except IndexError:
        raise OperationError(space.w_IndexError,
                             space.wrap("list deletion index out of range"))
    return space.w_None
Пример #9
0
def delitem__List_ANY(space, w_list, w_idx):
    idx = get_list_index(space, w_idx)
    if idx < 0:
        idx += w_list.length()
    try:
        w_list.pop(idx)
    except IndexError:
        raise OperationError(space.w_IndexError,
                             space.wrap("list deletion index out of range"))
    return space.w_None
Пример #10
0
def getitem__List_ANY(space, w_list, w_index):
    try:
        return w_list.wrappeditems[get_list_index(space, w_index)]
    except IndexError:
        raise OperationError(space.w_IndexError,
                             space.wrap("list index out of range"))
Пример #11
0
def getitem__List_ANY(space, w_list, w_index):
    try:
        return w_list.wrappeditems[get_list_index(space, w_index)]
    except IndexError:
        raise OperationError(space.w_IndexError,
                             space.wrap("list index out of range"))
Пример #12
0
def getitem__ListMulti_ANY(space, w_list, w_index):
    idx = get_list_index(space, w_index)
    idx = _adjust_index(space, idx, w_list.implementation.length(),
                        "list index out of range")
    return w_list.implementation.getitem(idx)
Пример #13
0
def setitem__ListMulti_ANY_ANY(space, w_list, w_index, w_any):
    idx = get_list_index(space, w_index)
    idx = _adjust_index(space, idx, w_list.implementation.length(),
                        "list index out of range")
    w_list.implementation = w_list.implementation.i_setitem(idx, w_any)
    return space.w_None