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