1cdef int CHKERR(int ierr) except -1: 2 if ierr==0: return 0 3 raise RuntimeError 4 5cdef int obj2int(object ob) except *: 6 return ob 7 8def foo(a): 9 """ 10 >>> foo(0) 11 >>> foo(1) 12 Traceback (most recent call last): 13 RuntimeError 14 """ 15 cdef int i = obj2int(a) 16 CHKERR(i) 17 18cdef int* except_expr(bint fire) except <int*>-1: 19 if fire: 20 raise RuntimeError 21 22def test_except_expr(bint fire): 23 """ 24 >>> test_except_expr(False) 25 >>> test_except_expr(True) 26 Traceback (most recent call last): 27 ... 28 RuntimeError 29 """ 30 except_expr(fire) 31 32cdef double except_big_result(bint fire) except 100000000000000000000000000000000: 33 if fire: 34 raise RuntimeError 35 36def test_except_big_result(bint fire): 37 """ 38 >>> test_except_big_result(False) 39 >>> test_except_big_result(True) 40 Traceback (most recent call last): 41 ... 42 RuntimeError 43 """ 44 except_big_result(fire) 45 46 47cdef unsigned short except_promotion_compare(bint fire) except *: 48 if fire: 49 raise RuntimeError 50 51def test_except_promotion_compare(bint fire): 52 """ 53 >>> test_except_promotion_compare(False) 54 >>> test_except_promotion_compare(True) 55 Traceback (most recent call last): 56 ... 57 RuntimeError 58 """ 59 except_promotion_compare(fire)