Commit 69088108 authored by Stefan Behnel's avatar Stefan Behnel

make wraparound() and boundscheck() available in pure mode

parent 7703feab
......@@ -27,6 +27,9 @@ Features added
* The ``PyTypeObject`` declaration in ``cpython.object`` was extended.
* ``wraparound()`` and ``boundscheck()`` are available as no-ops in pure
Python mode.
* ``NULL`` is allowed as default argument when embedding signatures.
This fixes ticket 843.
......
......@@ -97,7 +97,7 @@ class _EmptyDecoratorAndManager(object):
cclass = ccall = cfunc = _EmptyDecoratorAndManager()
returns = lambda type_arg: _EmptyDecoratorAndManager()
returns = wraparound = boundscheck = lambda arg: _EmptyDecoratorAndManager()
final = internal = type_version_tag = no_gc_clear = _empty_decorator
......
......@@ -5,6 +5,7 @@ is_compiled = cython.compiled
NULL = 5
_NULL = NULL
def test_sizeof():
"""
>>> test_sizeof()
......@@ -24,6 +25,7 @@ def test_sizeof():
else:
print(cython.sizeof(cython.char) == 1)
def test_declare(n):
"""
>>> test_declare(100)
......@@ -43,6 +45,7 @@ def test_declare(n):
ptr = cython.declare(cython.p_int, cython.address(y))
return y, ptr[0]
@cython.locals(x=cython.double, n=cython.int)
def test_cast(x):
"""
......@@ -52,6 +55,7 @@ def test_cast(x):
n = cython.cast(cython.int, x)
return n
@cython.locals(x=cython.int, y=cython.p_int)
def test_address(x):
"""
......@@ -61,6 +65,30 @@ def test_address(x):
y = cython.address(x)
return y[0]
@cython.wraparound(False)
def test_wraparound(x):
"""
>>> test_wraparound([1, 2, 3])
[1, 2, 1]
"""
with cython.wraparound(True):
x[-1] = x[0]
return x
@cython.boundscheck(False)
def test_boundscheck(x):
"""
>>> test_boundscheck([1, 2, 3])
3
>>> try: test_boundscheck([1, 2])
... except IndexError: pass
"""
with cython.boundscheck(True):
return x[2]
## CURRENTLY BROKEN - FIXME!!
## Is this test make sense? Implicit conversion in pure Python??
......@@ -74,6 +102,7 @@ def test_address(x):
## y = x
## return y
def test_with_nogil(nogil):
"""
>>> raised = []
......
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