Commit 3ef3ee7f authored by Stefan Behnel's avatar Stefan Behnel

add another straight exception case to macros

parent c7ff800a
...@@ -250,7 +250,8 @@ static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { ...@@ -250,7 +250,8 @@ static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
__Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) : \ __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) : \
__Pyx_GetItemInt_Generic(o, to_py_func(i))) (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), NULL) : \
__Pyx_GetItemInt_Generic(o, to_py_func(i))))
{{for type in ['List', 'Tuple']}} {{for type in ['List', 'Tuple']}}
#define __Pyx_GetItemInt_{{type}}(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ #define __Pyx_GetItemInt_{{type}}(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
...@@ -343,7 +344,8 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, ...@@ -343,7 +344,8 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ #define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
__Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) : \ __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) : \
__Pyx_SetItemInt_Generic(o, to_py_func(i), v)) (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) : \
__Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v); static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
...@@ -408,7 +410,8 @@ static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObje ...@@ -408,7 +410,8 @@ static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObje
#define __Pyx_DelItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ #define __Pyx_DelItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
__Pyx_DelItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound) : \ __Pyx_DelItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound) : \
__Pyx_DelItem_Generic(o, to_py_func(i))) (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) : \
__Pyx_DelItem_Generic(o, to_py_func(i))))
static CYTHON_INLINE int __Pyx_DelItem_Generic(PyObject *o, PyObject *j); static CYTHON_INLINE int __Pyx_DelItem_Generic(PyObject *o, PyObject *j);
static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i, static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i,
......
...@@ -75,6 +75,44 @@ def index_object(object o, int i): ...@@ -75,6 +75,44 @@ def index_object(object o, int i):
return o[i] return o[i]
def del_index_list(list L, Py_ssize_t index):
"""
>>> del_index_list(list(range(4)), 0)
[1, 2, 3]
>>> del_index_list(list(range(4)), 1)
[0, 2, 3]
>>> del_index_list(list(range(4)), -1)
[0, 1, 2]
>>> del_index_list(list(range(4)), py_maxsize)
Traceback (most recent call last):
IndexError: list assignment index out of range
>>> del_index_list(list(range(4)), -py_maxsize)
Traceback (most recent call last):
IndexError: list assignment index out of range
"""
del L[index]
return L
def set_index_list(list L, Py_ssize_t index):
"""
>>> set_index_list(list(range(4)), 0)
[5, 1, 2, 3]
>>> set_index_list(list(range(4)), 1)
[0, 5, 2, 3]
>>> set_index_list(list(range(4)), -1)
[0, 1, 2, 5]
>>> set_index_list(list(range(4)), py_maxsize)
Traceback (most recent call last):
IndexError: list assignment index out of range
>>> set_index_list(list(range(4)), -py_maxsize)
Traceback (most recent call last):
IndexError: list assignment index out of range
"""
L[index] = 5
return L
# These make sure that our fast indexing works with large and unsigned types. # These make sure that our fast indexing works with large and unsigned types.
def test_unsigned_long(): def test_unsigned_long():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment