Partial merge of trunk progress. Some tests still fail.
[cython.git] / tests / errors / nogil.pyx
1 # mode: error
2
3 cdef object f(object x) nogil:
4     pass
5
6 cdef void g(int x) nogil:
7     cdef object z
8     z = None
9
10 cdef void h(int x) nogil:
11     p()
12
13 cdef object p() nogil:
14     pass
15
16 cdef void r() nogil:
17     q()
18
19 cdef object m():
20     cdef object x, y, obj
21     cdef int i, j, k
22     global fred
23     q()
24     with nogil:
25         r()
26         q()
27         i = 42
28         obj = None
29         17L
30         <object>7j
31         help
32         `"Hello"`
33         import fred
34         from fred import obj
35         for x in obj:
36             pass
37         obj[i]
38         obj[i:j]
39         obj[i:j:k]
40         obj.fred
41         (x, y)
42         [x, y]
43         {x: y}
44         obj and x
45         t(obj)
46 #        f(42) # Cython handles this internally
47         x + obj
48         -obj
49         x = y = obj
50         x, y = y, x
51         obj[i] = x
52         obj.fred = x
53         print obj
54         del fred
55         return obj
56         raise obj
57         if obj:
58             pass
59         while obj:
60             pass
61         for x <= obj <= y:
62             pass
63         try:
64             pass
65         except:
66             pass
67         try:
68             pass
69         finally:
70             pass
71
72 cdef void q():
73     pass
74
75 cdef class C:
76     pass
77
78 cdef void t(C c) nogil:
79     pass
80
81 def ticket_338():
82     cdef object obj
83     with nogil:
84         for obj from 0 <= obj < 4:
85             pass
86
87 def bare_pyvar_name(object x):
88     with nogil:
89         x
90
91 # For m(), the important thing is that there are errors on all lines in the range 23-69
92 # except these: 29, 34, 44, 56, 58, 60, 62-64
93
94 _ERRORS = u"""
95 <<<<<<< HEAD
96 3:0: Function with Python return type cannot be declared nogil
97 6:0: Function declared nogil has Python locals or temporaries
98 8:6: Assignment of Python object not allowed without gil
99 11:5: Discarding owned Python object not allowed without gil
100 13:0: Function with Python return type cannot be declared nogil
101 17:5: Calling gil-requiring function not allowed without gil
102 26:9: Calling gil-requiring function not allowed without gil
103 28:12: Assignment of Python object not allowed without gil
104 30:8: Discarding owned Python object not allowed without gil
105 30:16: Constructing complex number not allowed without gil
106 32:8: Backquote expression not allowed without gil
107 32:8: Discarding owned Python object not allowed without gil
108 32:9: Operation not allowed without gil
109 33:15: Assignment of Python object not allowed without gil
110 33:15: Operation not allowed without gil
111 33:15: Python import not allowed without gil
112 34:8: Operation not allowed without gil
113 34:13: Python import not allowed without gil
114 34:25: Constructing Python list not allowed without gil
115 34:25: Operation not allowed without gil
116 35:17: Iterating over Python object not allowed without gil
117 37:11: Discarding owned Python object not allowed without gil
118 37:11: Indexing Python object not allowed without gil
119 38:11: Discarding owned Python object not allowed without gil
120 38:11: Slicing Python object not allowed without gil
121 39:11: Constructing Python slice object not allowed without gil
122 39:11: Discarding owned Python object not allowed without gil
123 39:11: Indexing Python object not allowed without gil
124 39:13: Converting to Python object not allowed without gil
125 39:15: Converting to Python object not allowed without gil
126 39:17: Converting to Python object not allowed without gil
127 40:11: Accessing Python attribute not allowed without gil
128 40:11: Discarding owned Python object not allowed without gil
129 41:9: Constructing Python tuple not allowed without gil
130 41:9: Discarding owned Python object not allowed without gil
131 42:8: Constructing Python list not allowed without gil
132 42:8: Discarding owned Python object not allowed without gil
133 43:8: Constructing Python dict not allowed without gil
134 43:8: Discarding owned Python object not allowed without gil
135 44:12: Discarding owned Python object not allowed without gil
136 44:12: Truth-testing Python object not allowed without gil
137 45:13: Python type test not allowed without gil
138 47:10: Discarding owned Python object not allowed without gil
139 47:10: Operation not allowed without gil
140 48:8: Discarding owned Python object not allowed without gil
141 48:8: Operation not allowed without gil
142 49:10: Assignment of Python object not allowed without gil
143 49:14: Assignment of Python object not allowed without gil
144 50:9: Assignment of Python object not allowed without gil
145 50:13: Assignment of Python object not allowed without gil
146 50:16: Creating temporary Python reference not allowed without gil
147 50:19: Creating temporary Python reference not allowed without gil
148 51:11: Assignment of Python object not allowed without gil
149 51:11: Indexing Python object not allowed without gil
150 52:11: Accessing Python attribute not allowed without gil
151 52:11: Assignment of Python object not allowed without gil
152 53:8: Constructing Python tuple not allowed without gil
153 53:8: Python print statement not allowed without gil
154 54:8: Deleting Python object not allowed without gil
155 55:8: Returning Python object not allowed without gil
156 56:8: Raising exception not allowed without gil
157 57:14: Truth-testing Python object not allowed without gil
158 59:17: Truth-testing Python object not allowed without gil
159 61:8: For-loop using object bounds or target not allowed without gil
160 63:8: Try-except statement not allowed without gil
161 67:8: Try-finally statement not allowed without gil
162 84:8: For-loop using object bounds or target not allowed without gil
163 """