From: Robert Bradshaw Date: Fri, 27 Feb 2009 06:25:55 +0000 (-0800) Subject: Fix to handle None or fast tuple/list indexing. X-Git-Tag: 0.11.rc~28 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2c9675ff61bb37967829684442bba721b5b93f1a;p=cython.git Fix to handle None or fast tuple/list indexing. --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 0e98374a..71885d31 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -5411,7 +5411,7 @@ static INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, Py_ssize_t i, int } static INLINE PyObject *__Pyx_GetItemInt_List(PyObject *o, Py_ssize_t i, int is_unsigned) { - if (likely(0 <= i && i < PyList_GET_SIZE(o))) { + if (likely(o != Py_None && 0 <= i && i < PyList_GET_SIZE(o))) { PyObject *r = PyList_GET_ITEM(o, i); Py_INCREF(r); return r; @@ -5420,7 +5420,7 @@ static INLINE PyObject *__Pyx_GetItemInt_List(PyObject *o, Py_ssize_t i, int is_ } static INLINE PyObject *__Pyx_GetItemInt_Tuple(PyObject *o, Py_ssize_t i, int is_unsigned) { - if (likely(0 <= i && i < PyTuple_GET_SIZE(o))) { + if (likely(o != Py_None && 0 <= i && i < PyTuple_GET_SIZE(o))) { PyObject *r = PyTuple_GET_ITEM(o, i); Py_INCREF(r); return r;