cython
1# mode: run
2# tag: cpp, werror
3
4cdef int raise_TypeError() except *:
5raise TypeError("custom")
6
7cdef extern from "cpp_exceptions_nogil_helper.h" nogil:
8cdef void foo "foo"(int i) except +
9cdef void bar "foo"(int i) except +ValueError
10cdef void spam"foo"(int i) except +raise_TypeError
11
12cdef int foo_nogil(int i) except * nogil:
13foo(i)
14
15def test_foo_nogil():
16"""
17>>> test_foo_nogil()
18"""
19foo_nogil(0)
20with nogil:
21foo_nogil(0)
22
23def test_foo():
24"""
25>>> test_foo()
26"""
27#
28foo(0)
29foo(0)
30with nogil:
31foo(0)
32foo(0)
33#
34try:
35with nogil:
36foo(0)
37finally:
38pass
39#
40try:
41with nogil:
42foo(0)
43with nogil:
44foo(0)
45finally:
46pass
47#
48try:
49with nogil:
50foo(0)
51with nogil:
52foo(1)
53except:
54with nogil:
55foo(0)
56finally:
57with nogil:
58foo(0)
59pass
60#
61try:
62with nogil:
63foo(0)
64foo(0)
65finally:
66pass
67#
68try:
69with nogil:
70foo(0)
71foo(1)
72except:
73with nogil:
74foo(0)
75finally:
76with nogil:
77foo(0)
78pass
79#
80try:
81with nogil:
82foo(0)
83try:
84with nogil:
85foo(1)
86except:
87with nogil:
88foo(1)
89finally:
90with nogil:
91foo(0)
92pass
93except:
94with nogil:
95foo(0)
96finally:
97with nogil:
98foo(0)
99pass
100#
101try:
102with nogil:
103foo(0)
104try:
105with nogil:
106foo(1)
107except:
108with nogil:
109foo(1)
110finally:
111with nogil:
112foo(1)
113pass
114except:
115with nogil:
116foo(0)
117finally:
118with nogil:
119foo(0)
120pass
121#
122
123def test_bar():
124"""
125>>> test_bar()
126"""
127#
128bar(0)
129bar(0)
130with nogil:
131bar(0)
132bar(0)
133#
134try:
135with nogil:
136bar(0)
137finally:
138pass
139#
140try:
141with nogil:
142bar(0)
143with nogil:
144bar(0)
145finally:
146pass
147#
148try:
149with nogil:
150bar(0)
151with nogil:
152bar(1)
153except ValueError:
154with nogil:
155bar(0)
156finally:
157with nogil:
158bar(0)
159pass
160#
161try:
162with nogil:
163bar(0)
164bar(0)
165finally:
166pass
167#
168try:
169with nogil:
170bar(0)
171bar(1)
172except ValueError:
173with nogil:
174bar(0)
175finally:
176with nogil:
177bar(0)
178pass
179#
180try:
181with nogil:
182bar(0)
183try:
184with nogil:
185bar(1)
186except ValueError:
187with nogil:
188bar(1)
189finally:
190with nogil:
191bar(0)
192pass
193except ValueError:
194with nogil:
195bar(0)
196finally:
197with nogil:
198bar(0)
199pass
200#
201try:
202with nogil:
203bar(0)
204try:
205with nogil:
206bar(1)
207except ValueError:
208with nogil:
209bar(1)
210finally:
211with nogil:
212bar(1)
213pass
214except ValueError:
215with nogil:
216bar(0)
217finally:
218with nogil:
219bar(0)
220pass
221#
222
223def test_spam():
224"""
225>>> test_spam()
226"""
227#
228spam(0)
229spam(0)
230with nogil:
231spam(0)
232spam(0)
233#
234try:
235with nogil:
236spam(0)
237finally:
238pass
239#
240try:
241with nogil:
242spam(0)
243with nogil:
244spam(0)
245finally:
246pass
247#
248try:
249with nogil:
250spam(0)
251with nogil:
252spam(1)
253except TypeError:
254with nogil:
255spam(0)
256finally:
257with nogil:
258spam(0)
259pass
260#
261try:
262with nogil:
263spam(0)
264spam(0)
265finally:
266pass
267#
268try:
269with nogil:
270spam(0)
271spam(1)
272except TypeError:
273with nogil:
274spam(0)
275finally:
276with nogil:
277spam(0)
278pass
279#
280try:
281with nogil:
282spam(0)
283try:
284with nogil:
285spam(1)
286except TypeError:
287with nogil:
288spam(1)
289finally:
290with nogil:
291spam(0)
292pass
293except TypeError:
294with nogil:
295spam(0)
296finally:
297with nogil:
298spam(0)
299pass
300#
301try:
302with nogil:
303spam(0)
304try:
305with nogil:
306spam(1)
307except TypeError:
308with nogil:
309spam(1)
310finally:
311with nogil:
312spam(1)
313pass
314except TypeError:
315with nogil:
316spam(0)
317finally:
318with nogil:
319spam(0)
320pass
321#
322