Cython has moved to github.
cython-devel
view tests/run/tryfinally.pyx @ 1622:4f0327bdebc9
test for temp allocation bug in call
| author | Robert Bradshaw <robertwb@math.washington.edu> |
|---|---|
| date | Sat Jan 17 01:25:34 2009 -0800 (3 years ago) |
| parents | 7f1b96cad687 |
| children | 49bf6a72fd64 |
line source
1 __doc__ = u"""
2 >>> try:
3 ... raise ValueError
4 ... finally:
5 ... raise TypeError
6 Traceback (most recent call last):
7 TypeError
8 >>> finally_except()
9 Traceback (most recent call last):
10 TypeError
12 >>> def try_return_py():
13 ... try:
14 ... return 1
15 ... finally:
16 ... return 2
17 >>> try_return_py()
18 2
19 >>> try_return_cy()
20 2
22 >>> i=1
23 >>> for i in range(3):
24 ... try:
25 ... continue
26 ... finally:
27 ... i+=1
28 >>> i
29 3
30 >>> try_continue(3)
31 3
32 """
34 def finally_except():
35 try:
36 raise ValueError
37 finally:
38 raise TypeError
40 def try_return_cy():
41 try:
42 return 1
43 finally:
44 return 2
46 def try_return_temp(a):
47 b = a+2
48 try:
49 c = a+b
50 return c
51 finally:
52 print b-a
54 def try_continue(a):
55 i=1
56 for i in range(a):
57 try:
58 continue
59 finally:
60 i+=1
61 return i
