Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_sys_settrace.py @ 87690:66c1c9f32567 default tip
Add use_weakref option to functools.lru_cache
The use_weakref option makes lru_cache create weak references to the function
arguments when creating the cache key, which prevents them from staying in the
memory forever even after all other references to them are gone.
This is a proof of concept for http://bugs.python.org/issue19859
| author | Radomir Dopieralski <devel@sheep.art.pl> |
|---|---|
| date | Tue, 03 Dec 2013 16:02:48 +0100 |
| parents | d18df4c90515 |
| children |
| rev | line source |
|---|---|
|
63210
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
1 # Testing the line trace facility. |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
2 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
3 from test import support |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
4 import unittest |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
5 import sys |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
6 import difflib |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
7 import gc |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
8 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
9 # A very basic example. If this fails, we're in deep trouble. |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
10 def basic(): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
11 return 1 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
12 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
13 basic.events = [(0, 'call'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
14 (1, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
15 (1, 'return')] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
16 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
17 # Many of the tests below are tricky because they involve pass statements. |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
18 # If there is implicit control flow around a pass statement (in an except |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
19 # clause or else caluse) under what conditions do you set a line number |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
20 # following that clause? |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
21 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
22 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
23 # The entire "while 0:" statement is optimized away. No code |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
24 # exists for it, so the line numbers skip directly from "del x" |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
25 # to "x = 1". |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
26 def arigo_example(): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
27 x = 1 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
28 del x |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
29 while 0: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
30 pass |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
31 x = 1 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
32 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
33 arigo_example.events = [(0, 'call'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
34 (1, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
35 (2, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
36 (5, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
37 (5, 'return')] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
38 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
39 # check that lines consisting of just one instruction get traced: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
40 def one_instr_line(): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
41 x = 1 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
42 del x |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
43 x = 1 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
44 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
45 one_instr_line.events = [(0, 'call'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
46 (1, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
47 (2, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
48 (3, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
49 (3, 'return')] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
50 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
51 def no_pop_tops(): # 0 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
52 x = 1 # 1 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
53 for a in range(2): # 2 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
54 if a: # 3 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
55 x = 1 # 4 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
56 else: # 5 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
57 x = 1 # 6 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
58 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
59 no_pop_tops.events = [(0, 'call'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
60 (1, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
61 (2, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
62 (3, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
63 (6, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
64 (2, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
65 (3, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
66 (4, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
67 (2, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
68 (2, 'return')] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
69 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
70 def no_pop_blocks(): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
71 y = 1 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
72 while not y: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
73 bla |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
74 x = 1 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
75 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
76 no_pop_blocks.events = [(0, 'call'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
77 (1, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
78 (2, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
79 (4, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
80 (4, 'return')] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
81 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
82 def called(): # line -3 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
83 x = 1 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
84 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
85 def call(): # line 0 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
86 called() |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
87 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
88 call.events = [(0, 'call'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
89 (1, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
90 (-3, 'call'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
91 (-2, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
92 (-2, 'return'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
93 (1, 'return')] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
94 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
95 def raises(): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
96 raise Exception |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
97 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
98 def test_raise(): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
99 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
100 raises() |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
101 except Exception as exc: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
102 x = 1 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
103 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
104 test_raise.events = [(0, 'call'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
105 (1, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
106 (2, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
107 (-3, 'call'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
108 (-2, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
109 (-2, 'exception'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
110 (-2, 'return'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
111 (2, 'exception'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
112 (3, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
113 (4, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
114 (4, 'return')] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
115 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
116 def _settrace_and_return(tracefunc): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
117 sys.settrace(tracefunc) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
118 sys._getframe().f_back.f_trace = tracefunc |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
119 def settrace_and_return(tracefunc): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
120 _settrace_and_return(tracefunc) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
121 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
122 settrace_and_return.events = [(1, 'return')] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
123 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
124 def _settrace_and_raise(tracefunc): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
125 sys.settrace(tracefunc) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
126 sys._getframe().f_back.f_trace = tracefunc |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
127 raise RuntimeError |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
128 def settrace_and_raise(tracefunc): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
129 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
130 _settrace_and_raise(tracefunc) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
131 except RuntimeError as exc: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
132 pass |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
133 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
134 settrace_and_raise.events = [(2, 'exception'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
135 (3, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
136 (4, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
137 (4, 'return')] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
138 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
139 # implicit return example |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
140 # This test is interesting because of the else: pass |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
141 # part of the code. The code generate for the true |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
142 # part of the if contains a jump past the else branch. |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
143 # The compiler then generates an implicit "return None" |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
144 # Internally, the compiler visits the pass statement |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
145 # and stores its line number for use on the next instruction. |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
146 # The next instruction is the implicit return None. |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
147 def ireturn_example(): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
148 a = 5 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
149 b = 5 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
150 if a == b: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
151 b = a+1 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
152 else: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
153 pass |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
154 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
155 ireturn_example.events = [(0, 'call'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
156 (1, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
157 (2, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
158 (3, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
159 (4, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
160 (6, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
161 (6, 'return')] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
162 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
163 # Tight loop with while(1) example (SF #765624) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
164 def tightloop_example(): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
165 items = range(0, 3) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
166 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
167 i = 0 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
168 while 1: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
169 b = items[i]; i+=1 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
170 except IndexError: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
171 pass |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
172 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
173 tightloop_example.events = [(0, 'call'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
174 (1, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
175 (2, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
176 (3, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
177 (4, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
178 (5, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
179 (5, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
180 (5, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
181 (5, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
182 (5, 'exception'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
183 (6, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
184 (7, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
185 (7, 'return')] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
186 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
187 def tighterloop_example(): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
188 items = range(1, 4) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
189 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
190 i = 0 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
191 while 1: i = items[i] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
192 except IndexError: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
193 pass |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
194 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
195 tighterloop_example.events = [(0, 'call'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
196 (1, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
197 (2, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
198 (3, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
199 (4, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
200 (4, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
201 (4, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
202 (4, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
203 (4, 'exception'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
204 (5, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
205 (6, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
206 (6, 'return')] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
207 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
208 def generator_function(): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
209 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
210 yield True |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
211 "continued" |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
212 finally: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
213 "finally" |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
214 def generator_example(): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
215 # any() will leave the generator before its end |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
216 x = any(generator_function()) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
217 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
218 # the following lines were not traced |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
219 for x in range(10): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
220 y = x |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
221 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
222 generator_example.events = ([(0, 'call'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
223 (2, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
224 (-6, 'call'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
225 (-5, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
226 (-4, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
227 (-4, 'return'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
228 (-4, 'call'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
229 (-4, 'exception'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
230 (-1, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
231 (-1, 'return')] + |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
232 [(5, 'line'), (6, 'line')] * 10 + |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
233 [(5, 'line'), (5, 'return')]) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
234 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
235 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
236 class Tracer: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
237 def __init__(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
238 self.events = [] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
239 def trace(self, frame, event, arg): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
240 self.events.append((frame.f_lineno, event)) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
241 return self.trace |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
242 def traceWithGenexp(self, frame, event, arg): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
243 (o for o in [1]) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
244 self.events.append((frame.f_lineno, event)) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
245 return self.trace |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
246 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
247 class TraceTestCase(unittest.TestCase): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
248 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
249 # Disable gc collection when tracing, otherwise the |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
250 # deallocators may be traced as well. |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
251 def setUp(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
252 self.using_gc = gc.isenabled() |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
253 gc.disable() |
|
68080
614e32900ef7
Issue #10990: Prevent tests from clobbering a set trace function.
Brett Cannon <bcannon@gmail.com>
parents:
63206
diff
changeset
|
254 self.addCleanup(sys.settrace, sys.gettrace()) |
|
63210
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
255 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
256 def tearDown(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
257 if self.using_gc: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
258 gc.enable() |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
259 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
260 def compare_events(self, line_offset, events, expected_events): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
261 events = [(l - line_offset, e) for (l, e) in events] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
262 if events != expected_events: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
263 self.fail( |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
264 "events did not match expectation:\n" + |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
265 "\n".join(difflib.ndiff([str(x) for x in expected_events], |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
266 [str(x) for x in events]))) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
267 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
268 def run_and_compare(self, func, events): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
269 tracer = Tracer() |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
270 sys.settrace(tracer.trace) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
271 func() |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
272 sys.settrace(None) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
273 self.compare_events(func.__code__.co_firstlineno, |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
274 tracer.events, events) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
275 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
276 def run_test(self, func): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
277 self.run_and_compare(func, func.events) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
278 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
279 def run_test2(self, func): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
280 tracer = Tracer() |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
281 func(tracer.trace) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
282 sys.settrace(None) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
283 self.compare_events(func.__code__.co_firstlineno, |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
284 tracer.events, func.events) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
285 |
|
72708
a0393cbe4872
Enable the only tests for sys.gettrace
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
68257
diff
changeset
|
286 def test_set_and_retrieve_none(self): |
|
63210
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
287 sys.settrace(None) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
288 assert sys.gettrace() is None |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
289 |
|
72708
a0393cbe4872
Enable the only tests for sys.gettrace
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
68257
diff
changeset
|
290 def test_set_and_retrieve_func(self): |
|
63210
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
291 def fn(*args): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
292 pass |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
293 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
294 sys.settrace(fn) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
295 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
296 assert sys.gettrace() is fn |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
297 finally: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
298 sys.settrace(None) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
299 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
300 def test_01_basic(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
301 self.run_test(basic) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
302 def test_02_arigo(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
303 self.run_test(arigo_example) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
304 def test_03_one_instr(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
305 self.run_test(one_instr_line) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
306 def test_04_no_pop_blocks(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
307 self.run_test(no_pop_blocks) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
308 def test_05_no_pop_tops(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
309 self.run_test(no_pop_tops) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
310 def test_06_call(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
311 self.run_test(call) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
312 def test_07_raise(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
313 self.run_test(test_raise) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
314 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
315 def test_08_settrace_and_return(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
316 self.run_test2(settrace_and_return) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
317 def test_09_settrace_and_raise(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
318 self.run_test2(settrace_and_raise) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
319 def test_10_ireturn(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
320 self.run_test(ireturn_example) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
321 def test_11_tightloop(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
322 self.run_test(tightloop_example) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
323 def test_12_tighterloop(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
324 self.run_test(tighterloop_example) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
325 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
326 def test_13_genexp(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
327 self.run_test(generator_example) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
328 # issue1265: if the trace function contains a generator, |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
329 # and if the traced function contains another generator |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
330 # that is not completely exhausted, the trace stopped. |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
331 # Worse: the 'finally' clause was not invoked. |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
332 tracer = Tracer() |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
333 sys.settrace(tracer.traceWithGenexp) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
334 generator_example() |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
335 sys.settrace(None) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
336 self.compare_events(generator_example.__code__.co_firstlineno, |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
337 tracer.events, generator_example.events) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
338 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
339 def test_14_onliner_if(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
340 def onliners(): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
341 if True: False |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
342 else: True |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
343 return 0 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
344 self.run_and_compare( |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
345 onliners, |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
346 [(0, 'call'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
347 (1, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
348 (3, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
349 (3, 'return')]) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
350 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
351 def test_15_loops(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
352 # issue1750076: "while" expression is skipped by debugger |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
353 def for_example(): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
354 for x in range(2): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
355 pass |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
356 self.run_and_compare( |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
357 for_example, |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
358 [(0, 'call'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
359 (1, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
360 (2, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
361 (1, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
362 (2, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
363 (1, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
364 (1, 'return')]) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
365 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
366 def while_example(): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
367 # While expression should be traced on every loop |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
368 x = 2 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
369 while x > 0: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
370 x -= 1 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
371 self.run_and_compare( |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
372 while_example, |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
373 [(0, 'call'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
374 (2, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
375 (3, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
376 (4, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
377 (3, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
378 (4, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
379 (3, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
380 (3, 'return')]) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
381 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
382 def test_16_blank_lines(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
383 namespace = {} |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
384 exec("def f():\n" + "\n" * 256 + " pass", namespace) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
385 self.run_and_compare( |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
386 namespace["f"], |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
387 [(0, 'call'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
388 (257, 'line'), |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
389 (257, 'return')]) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
390 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
391 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
392 class RaisingTraceFuncTestCase(unittest.TestCase): |
|
68080
614e32900ef7
Issue #10990: Prevent tests from clobbering a set trace function.
Brett Cannon <bcannon@gmail.com>
parents:
63206
diff
changeset
|
393 def setUp(self): |
|
614e32900ef7
Issue #10990: Prevent tests from clobbering a set trace function.
Brett Cannon <bcannon@gmail.com>
parents:
63206
diff
changeset
|
394 self.addCleanup(sys.settrace, sys.gettrace()) |
|
614e32900ef7
Issue #10990: Prevent tests from clobbering a set trace function.
Brett Cannon <bcannon@gmail.com>
parents:
63206
diff
changeset
|
395 |
|
63210
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
396 def trace(self, frame, event, arg): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
397 """A trace function that raises an exception in response to a |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
398 specific trace event.""" |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
399 if event == self.raiseOnEvent: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
400 raise ValueError # just something that isn't RuntimeError |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
401 else: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
402 return self.trace |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
403 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
404 def f(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
405 """The function to trace; raises an exception if that's the case |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
406 we're testing, so that the 'exception' trace event fires.""" |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
407 if self.raiseOnEvent == 'exception': |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
408 x = 0 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
409 y = 1/x |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
410 else: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
411 return 1 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
412 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
413 def run_test_for_event(self, event): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
414 """Tests that an exception raised in response to the given event is |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
415 handled OK.""" |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
416 self.raiseOnEvent = event |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
417 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
418 for i in range(sys.getrecursionlimit() + 1): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
419 sys.settrace(self.trace) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
420 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
421 self.f() |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
422 except ValueError: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
423 pass |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
424 else: |
|
80928
fdf907708f49
Issue #16714: use 'raise' exceptions, don't 'throw'.
Andrew Svetlov <andrew.svetlov@gmail.com>
parents:
76393
diff
changeset
|
425 self.fail("exception not raised!") |
|
63210
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
426 except RuntimeError: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
427 self.fail("recursion counter not reset") |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
428 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
429 # Test the handling of exceptions raised by each kind of trace event. |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
430 def test_call(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
431 self.run_test_for_event('call') |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
432 def test_line(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
433 self.run_test_for_event('line') |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
434 def test_return(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
435 self.run_test_for_event('return') |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
436 def test_exception(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
437 self.run_test_for_event('exception') |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
438 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
439 def test_trash_stack(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
440 def f(): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
441 for i in range(5): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
442 print(i) # line tracing will raise an exception at this line |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
443 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
444 def g(frame, why, extra): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
445 if (why == 'line' and |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
446 frame.f_lineno == f.__code__.co_firstlineno + 2): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
447 raise RuntimeError("i am crashing") |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
448 return g |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
449 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
450 sys.settrace(g) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
451 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
452 f() |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
453 except RuntimeError: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
454 # the test is really that this doesn't segfault: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
455 import gc |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
456 gc.collect() |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
457 else: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
458 self.fail("exception not propagated") |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
459 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
460 |
|
83455
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
461 def test_exception_arguments(self): |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
462 def f(): |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
463 x = 0 |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
464 # this should raise an error |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
465 x.no_such_attr |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
466 def g(frame, event, arg): |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
467 if (event == 'exception'): |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
468 type, exception, trace = arg |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
469 self.assertIsInstance(exception, Exception) |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
470 return g |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
471 |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
472 existing = sys.gettrace() |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
473 try: |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
474 sys.settrace(g) |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
475 try: |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
476 f() |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
477 except AttributeError: |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
478 # this is expected |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
479 pass |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
480 finally: |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
481 sys.settrace(existing) |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
482 |
|
d18df4c90515
#17413: make sure settrace funcs get passed exception instances for 'value'.
R David Murray <rdmurray@bitdance.com>
parents:
80929
diff
changeset
|
483 |
|
63210
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
484 # 'Jump' tests: assigning to frame.f_lineno within a trace function |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
485 # moves the execution position - it's how debuggers implement a Jump |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
486 # command (aka. "Set next statement"). |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
487 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
488 class JumpTracer: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
489 """Defines a trace function that jumps from one place to another, |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
490 with the source and destination lines of the jump being defined by |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
491 the 'jump' property of the function under test.""" |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
492 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
493 def __init__(self, function): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
494 self.function = function |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
495 self.jumpFrom = function.jump[0] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
496 self.jumpTo = function.jump[1] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
497 self.done = False |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
498 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
499 def trace(self, frame, event, arg): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
500 if not self.done and frame.f_code == self.function.__code__: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
501 firstLine = frame.f_code.co_firstlineno |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
502 if event == 'line' and frame.f_lineno == firstLine + self.jumpFrom: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
503 # Cope with non-integer self.jumpTo (because of |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
504 # no_jump_to_non_integers below). |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
505 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
506 frame.f_lineno = firstLine + self.jumpTo |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
507 except TypeError: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
508 frame.f_lineno = self.jumpTo |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
509 self.done = True |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
510 return self.trace |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
511 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
512 # The first set of 'jump' tests are for things that are allowed: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
513 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
514 def jump_simple_forwards(output): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
515 output.append(1) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
516 output.append(2) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
517 output.append(3) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
518 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
519 jump_simple_forwards.jump = (1, 3) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
520 jump_simple_forwards.output = [3] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
521 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
522 def jump_simple_backwards(output): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
523 output.append(1) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
524 output.append(2) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
525 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
526 jump_simple_backwards.jump = (2, 1) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
527 jump_simple_backwards.output = [1, 1, 2] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
528 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
529 def jump_out_of_block_forwards(output): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
530 for i in 1, 2: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
531 output.append(2) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
532 for j in [3]: # Also tests jumping over a block |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
533 output.append(4) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
534 output.append(5) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
535 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
536 jump_out_of_block_forwards.jump = (3, 5) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
537 jump_out_of_block_forwards.output = [2, 5] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
538 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
539 def jump_out_of_block_backwards(output): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
540 output.append(1) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
541 for i in [1]: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
542 output.append(3) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
543 for j in [2]: # Also tests jumping over a block |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
544 output.append(5) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
545 output.append(6) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
546 output.append(7) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
547 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
548 jump_out_of_block_backwards.jump = (6, 1) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
549 jump_out_of_block_backwards.output = [1, 3, 5, 1, 3, 5, 6, 7] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
550 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
551 def jump_to_codeless_line(output): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
552 output.append(1) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
553 # Jumping to this line should skip to the next one. |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
554 output.append(3) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
555 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
556 jump_to_codeless_line.jump = (1, 2) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
557 jump_to_codeless_line.output = [3] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
558 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
559 def jump_to_same_line(output): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
560 output.append(1) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
561 output.append(2) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
562 output.append(3) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
563 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
564 jump_to_same_line.jump = (2, 2) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
565 jump_to_same_line.output = [1, 2, 3] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
566 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
567 # Tests jumping within a finally block, and over one. |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
568 def jump_in_nested_finally(output): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
569 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
570 output.append(2) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
571 finally: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
572 output.append(4) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
573 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
574 output.append(6) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
575 finally: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
576 output.append(8) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
577 output.append(9) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
578 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
579 jump_in_nested_finally.jump = (4, 9) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
580 jump_in_nested_finally.output = [2, 9] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
581 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
582 # The second set of 'jump' tests are for things that are not allowed: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
583 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
584 def no_jump_too_far_forwards(output): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
585 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
586 output.append(2) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
587 output.append(3) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
588 except ValueError as e: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
589 output.append('after' in str(e)) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
590 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
591 no_jump_too_far_forwards.jump = (3, 6) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
592 no_jump_too_far_forwards.output = [2, True] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
593 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
594 def no_jump_too_far_backwards(output): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
595 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
596 output.append(2) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
597 output.append(3) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
598 except ValueError as e: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
599 output.append('before' in str(e)) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
600 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
601 no_jump_too_far_backwards.jump = (3, -1) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
602 no_jump_too_far_backwards.output = [2, True] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
603 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
604 # Test each kind of 'except' line. |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
605 def no_jump_to_except_1(output): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
606 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
607 output.append(2) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
608 except: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
609 e = sys.exc_info()[1] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
610 output.append('except' in str(e)) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
611 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
612 no_jump_to_except_1.jump = (2, 3) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
613 no_jump_to_except_1.output = [True] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
614 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
615 def no_jump_to_except_2(output): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
616 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
617 output.append(2) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
618 except ValueError: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
619 e = sys.exc_info()[1] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
620 output.append('except' in str(e)) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
621 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
622 no_jump_to_except_2.jump = (2, 3) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
623 no_jump_to_except_2.output = [True] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
624 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
625 def no_jump_to_except_3(output): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
626 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
627 output.append(2) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
628 except ValueError as e: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
629 output.append('except' in str(e)) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
630 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
631 no_jump_to_except_3.jump = (2, 3) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
632 no_jump_to_except_3.output = [True] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
633 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
634 def no_jump_to_except_4(output): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
635 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
636 output.append(2) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
637 except (ValueError, RuntimeError) as e: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
638 output.append('except' in str(e)) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
639 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
640 no_jump_to_except_4.jump = (2, 3) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
641 no_jump_to_except_4.output = [True] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
642 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
643 def no_jump_forwards_into_block(output): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
644 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
645 output.append(2) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
646 for i in 1, 2: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
647 output.append(4) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
648 except ValueError as e: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
649 output.append('into' in str(e)) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
650 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
651 no_jump_forwards_into_block.jump = (2, 4) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
652 no_jump_forwards_into_block.output = [True] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
653 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
654 def no_jump_backwards_into_block(output): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
655 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
656 for i in 1, 2: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
657 output.append(3) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
658 output.append(4) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
659 except ValueError as e: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
660 output.append('into' in str(e)) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
661 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
662 no_jump_backwards_into_block.jump = (4, 3) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
663 no_jump_backwards_into_block.output = [3, 3, True] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
664 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
665 def no_jump_into_finally_block(output): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
666 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
667 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
668 output.append(3) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
669 x = 1 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
670 finally: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
671 output.append(6) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
672 except ValueError as e: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
673 output.append('finally' in str(e)) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
674 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
675 no_jump_into_finally_block.jump = (4, 6) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
676 no_jump_into_finally_block.output = [3, 6, True] # The 'finally' still runs |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
677 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
678 def no_jump_out_of_finally_block(output): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
679 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
680 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
681 output.append(3) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
682 finally: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
683 output.append(5) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
684 output.append(6) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
685 except ValueError as e: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
686 output.append('finally' in str(e)) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
687 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
688 no_jump_out_of_finally_block.jump = (5, 1) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
689 no_jump_out_of_finally_block.output = [3, True] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
690 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
691 # This verifies the line-numbers-must-be-integers rule. |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
692 def no_jump_to_non_integers(output): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
693 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
694 output.append(2) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
695 except ValueError as e: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
696 output.append('integer' in str(e)) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
697 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
698 no_jump_to_non_integers.jump = (2, "Spam") |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
699 no_jump_to_non_integers.output = [True] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
700 |
|
76393
6a0a073e8461
SETUP_WITH acts like SETUP_FINALLY for the purposes of setting f_lineno (closes #14612)
Benjamin Peterson <benjamin@python.org>
parents:
72708
diff
changeset
|
701 def jump_across_with(output): |
|
6a0a073e8461
SETUP_WITH acts like SETUP_FINALLY for the purposes of setting f_lineno (closes #14612)
Benjamin Peterson <benjamin@python.org>
parents:
72708
diff
changeset
|
702 with open(support.TESTFN, "wb") as fp: |
|
6a0a073e8461
SETUP_WITH acts like SETUP_FINALLY for the purposes of setting f_lineno (closes #14612)
Benjamin Peterson <benjamin@python.org>
parents:
72708
diff
changeset
|
703 pass |
|
6a0a073e8461
SETUP_WITH acts like SETUP_FINALLY for the purposes of setting f_lineno (closes #14612)
Benjamin Peterson <benjamin@python.org>
parents:
72708
diff
changeset
|
704 with open(support.TESTFN, "wb") as fp: |
|
6a0a073e8461
SETUP_WITH acts like SETUP_FINALLY for the purposes of setting f_lineno (closes #14612)
Benjamin Peterson <benjamin@python.org>
parents:
72708
diff
changeset
|
705 pass |
|
6a0a073e8461
SETUP_WITH acts like SETUP_FINALLY for the purposes of setting f_lineno (closes #14612)
Benjamin Peterson <benjamin@python.org>
parents:
72708
diff
changeset
|
706 jump_across_with.jump = (1, 3) |
|
6a0a073e8461
SETUP_WITH acts like SETUP_FINALLY for the purposes of setting f_lineno (closes #14612)
Benjamin Peterson <benjamin@python.org>
parents:
72708
diff
changeset
|
707 jump_across_with.output = [] |
|
6a0a073e8461
SETUP_WITH acts like SETUP_FINALLY for the purposes of setting f_lineno (closes #14612)
Benjamin Peterson <benjamin@python.org>
parents:
72708
diff
changeset
|
708 |
|
63210
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
709 # This verifies that you can't set f_lineno via _getframe or similar |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
710 # trickery. |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
711 def no_jump_without_trace_function(): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
712 try: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
713 previous_frame = sys._getframe().f_back |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
714 previous_frame.f_lineno = previous_frame.f_lineno |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
715 except ValueError as e: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
716 # This is the exception we wanted; make sure the error message |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
717 # talks about trace functions. |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
718 if 'trace' not in str(e): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
719 raise |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
720 else: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
721 # Something's wrong - the expected exception wasn't raised. |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
722 raise RuntimeError("Trace-function-less jump failed to fail") |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
723 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
724 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
725 class JumpTestCase(unittest.TestCase): |
|
68080
614e32900ef7
Issue #10990: Prevent tests from clobbering a set trace function.
Brett Cannon <bcannon@gmail.com>
parents:
63206
diff
changeset
|
726 def setUp(self): |
|
614e32900ef7
Issue #10990: Prevent tests from clobbering a set trace function.
Brett Cannon <bcannon@gmail.com>
parents:
63206
diff
changeset
|
727 self.addCleanup(sys.settrace, sys.gettrace()) |
|
614e32900ef7
Issue #10990: Prevent tests from clobbering a set trace function.
Brett Cannon <bcannon@gmail.com>
parents:
63206
diff
changeset
|
728 sys.settrace(None) |
|
614e32900ef7
Issue #10990: Prevent tests from clobbering a set trace function.
Brett Cannon <bcannon@gmail.com>
parents:
63206
diff
changeset
|
729 |
|
63210
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
730 def compare_jump_output(self, expected, received): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
731 if received != expected: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
732 self.fail( "Outputs don't match:\n" + |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
733 "Expected: " + repr(expected) + "\n" + |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
734 "Received: " + repr(received)) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
735 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
736 def run_test(self, func): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
737 tracer = JumpTracer(func) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
738 sys.settrace(tracer.trace) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
739 output = [] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
740 func(output) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
741 sys.settrace(None) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
742 self.compare_jump_output(func.output, output) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
743 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
744 def test_01_jump_simple_forwards(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
745 self.run_test(jump_simple_forwards) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
746 def test_02_jump_simple_backwards(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
747 self.run_test(jump_simple_backwards) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
748 def test_03_jump_out_of_block_forwards(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
749 self.run_test(jump_out_of_block_forwards) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
750 def test_04_jump_out_of_block_backwards(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
751 self.run_test(jump_out_of_block_backwards) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
752 def test_05_jump_to_codeless_line(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
753 self.run_test(jump_to_codeless_line) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
754 def test_06_jump_to_same_line(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
755 self.run_test(jump_to_same_line) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
756 def test_07_jump_in_nested_finally(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
757 self.run_test(jump_in_nested_finally) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
758 def test_08_no_jump_too_far_forwards(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
759 self.run_test(no_jump_too_far_forwards) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
760 def test_09_no_jump_too_far_backwards(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
761 self.run_test(no_jump_too_far_backwards) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
762 def test_10_no_jump_to_except_1(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
763 self.run_test(no_jump_to_except_1) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
764 def test_11_no_jump_to_except_2(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
765 self.run_test(no_jump_to_except_2) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
766 def test_12_no_jump_to_except_3(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
767 self.run_test(no_jump_to_except_3) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
768 def test_13_no_jump_to_except_4(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
769 self.run_test(no_jump_to_except_4) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
770 def test_14_no_jump_forwards_into_block(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
771 self.run_test(no_jump_forwards_into_block) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
772 def test_15_no_jump_backwards_into_block(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
773 self.run_test(no_jump_backwards_into_block) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
774 def test_16_no_jump_into_finally_block(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
775 self.run_test(no_jump_into_finally_block) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
776 def test_17_no_jump_out_of_finally_block(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
777 self.run_test(no_jump_out_of_finally_block) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
778 def test_18_no_jump_to_non_integers(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
779 self.run_test(no_jump_to_non_integers) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
780 def test_19_no_jump_without_trace_function(self): |
|
68080
614e32900ef7
Issue #10990: Prevent tests from clobbering a set trace function.
Brett Cannon <bcannon@gmail.com>
parents:
63206
diff
changeset
|
781 # Must set sys.settrace(None) in setUp(), else condition is not |
|
614e32900ef7
Issue #10990: Prevent tests from clobbering a set trace function.
Brett Cannon <bcannon@gmail.com>
parents:
63206
diff
changeset
|
782 # triggered. |
|
63210
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
783 no_jump_without_trace_function() |
|
76393
6a0a073e8461
SETUP_WITH acts like SETUP_FINALLY for the purposes of setting f_lineno (closes #14612)
Benjamin Peterson <benjamin@python.org>
parents:
72708
diff
changeset
|
784 def test_jump_across_with(self): |
|
6a0a073e8461
SETUP_WITH acts like SETUP_FINALLY for the purposes of setting f_lineno (closes #14612)
Benjamin Peterson <benjamin@python.org>
parents:
72708
diff
changeset
|
785 self.addCleanup(support.unlink, support.TESTFN) |
|
6a0a073e8461
SETUP_WITH acts like SETUP_FINALLY for the purposes of setting f_lineno (closes #14612)
Benjamin Peterson <benjamin@python.org>
parents:
72708
diff
changeset
|
786 self.run_test(jump_across_with) |
|
63210
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
787 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
788 def test_20_large_function(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
789 d = {} |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
790 exec("""def f(output): # line 0 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
791 x = 0 # line 1 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
792 y = 1 # line 2 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
793 ''' # line 3 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
794 %s # lines 4-1004 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
795 ''' # line 1005 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
796 x += 1 # line 1006 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
797 output.append(x) # line 1007 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
798 return""" % ('\n' * 1000,), d) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
799 f = d['f'] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
800 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
801 f.jump = (2, 1007) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
802 f.output = [0] |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
803 self.run_test(f) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
804 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
805 def test_jump_to_firstlineno(self): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
806 # This tests that PDB can jump back to the first line in a |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
807 # file. See issue #1689458. It can only be triggered in a |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
808 # function call if the function is defined on a single line. |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
809 code = compile(""" |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
810 # Comments don't count. |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
811 output.append(2) # firstlineno is here. |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
812 output.append(3) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
813 output.append(4) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
814 """, "<fake module>", "exec") |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
815 class fake_function: |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
816 __code__ = code |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
817 jump = (2, 0) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
818 tracer = JumpTracer(fake_function) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
819 sys.settrace(tracer.trace) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
820 namespace = {"output": []} |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
821 exec(code, namespace) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
822 sys.settrace(None) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
823 self.compare_jump_output([2, 3, 2, 3, 4], namespace["output"]) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
824 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
825 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
826 def test_main(): |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
827 support.run_unittest( |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
828 TraceTestCase, |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
829 RaisingTraceFuncTestCase, |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
830 JumpTestCase |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
831 ) |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
832 |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
833 if __name__ == "__main__": |
|
b19f8a4929d5
Reverted r83143: svnmerge failed to add new names
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
834 test_main() |
