merge
[cython.git] / tests / errors / e_bufaccess2.pyx
1 cimport e_bufaccess_pxd # was needed to provoke a bug involving ErrorType
2 import cython
3
4 def f():
5     cdef object[e_bufaccess_pxd.T] buf
6
7 def withnogil_access_fail():
8     cdef object[int] buf = None
9     with nogil:
10         buf[2] = 2
11
12 @cython.boundscheck(False)
13 def withnogil_access_ok():
14     cdef object[int] buf = None
15     with nogil:
16         buf[2] = 2 # No error should be triggered here
17
18 @cython.boundscheck(False)
19 def withnogil_access_fail_2():
20     cdef object[object] buf = None
21     with nogil:
22         buf[2] = 2 # Not OK as dtype is object
23
24 def withnogil_acquire(x):
25     cdef object[int] buf
26     with nogil:
27         buf = x
28
29 _ERRORS = u"""
30 3:9: 'nothing' is not a type identifier
31 10:11: Cannot check buffer index bounds without gil; use boundscheck(False) directive
32 22:11: Cannot access buffer with object dtype without gil
33 22:11: Assignment of Python object not allowed without gil
34 27:12: Assignment of Python object not allowed without gil
35 """