File: e_bufaccess2.pyx

package info (click to toggle)
cython 3.0.11%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 19,092 kB
  • sloc: python: 83,539; ansic: 18,831; cpp: 1,402; xml: 1,031; javascript: 511; makefile: 403; sh: 204; sed: 11
file content (36 lines) | stat: -rw-r--r-- 885 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# mode: error

cimport e_bufaccess_pxd # was needed to provoke a bug involving ErrorType
import cython

def f():
    cdef object[e_bufaccess_pxd.T] buf

def withnogil_access_fail():
    cdef object[int] buf = None
    with nogil:
        buf[2] = 2

@cython.boundscheck(False)
def withnogil_access_ok():
    cdef object[int] buf = None
    with nogil:
        buf[2] = 2 # No error should be triggered here

@cython.boundscheck(False)
def withnogil_access_fail_2():
    cdef object[object] buf = None
    with nogil:
        buf[2] = 2 # Not OK as dtype is object

def withnogil_acquire(x):
    cdef object[int] buf
    with nogil:
        buf = x

_ERRORS = u"""
 3: 9: 'nothing' is not a type identifier
24:11: Cannot access buffer with object dtype without gil
24:11: Assignment of Python object not allowed without gil
29:8: Assignment of Python object not allowed without gil
"""