From: Robert Bradshaw Date: Wed, 9 Dec 2009 06:21:37 +0000 (-0800) Subject: List/tuple boundscheck test. X-Git-Tag: 0.12.1~54 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=31ca96cd2833e1d0228a4d83e7c327ca93761003;p=cython.git List/tuple boundscheck test. --- diff --git a/tests/run/index.pyx b/tests/run/index.pyx index 7003755f..1b6fd68e 100644 --- a/tests/run/index.pyx +++ b/tests/run/index.pyx @@ -11,6 +11,7 @@ if sys.version_info[0] >= 3: elif sys.version_info < (2,5): __doc__ = __doc__.replace(u"'int' object is unsubscriptable", u'unsubscriptable object') +import cython def index_tuple(tuple t, int i): """ @@ -113,3 +114,15 @@ def test_long_long(): assert D[ix] is True del D[ix] assert len(D) == 0 + +@cython.boundscheck(False) +def test_boundscheck(list L, tuple t, object o, unsigned long ix): + """ + >>> test_boundscheck([1, 2, 4], (1, 2, 4), [1, 2, 4], 2) + (4, 4, 4) + >>> test_boundscheck([1, 2, 4], (1, 2, 4), "", 2) + Traceback (most recent call last): + ... + IndexError: string index out of range + """ + return L[ix], t[ix], o[ix]