Show More
@@ -43,15 +43,15 b' def doctest_tb_plain():' | |||||
43 | In [18]: xmode plain |
|
43 | In [18]: xmode plain | |
44 | Exception reporting mode: Plain |
|
44 | Exception reporting mode: Plain | |
45 |
|
45 | |||
46 | In [19]: run simpleerr.py |
|
46 | In [19]: run simpleerr.py | |
47 | Traceback (most recent call last): |
|
47 | Traceback (most recent call last): | |
48 |
...line |
|
48 | ...line ..., in <module> | |
49 | bar(mode) |
|
49 | bar(mode) | |
50 |
...line |
|
50 | ...line ..., in bar | |
51 | div0() |
|
51 | div0() | |
52 |
...line |
|
52 | ...line ..., in div0 | |
53 | x/y |
|
53 | x/y | |
54 | ZeroDivisionError: ... |
|
54 | ZeroDivisionError: ... | |
55 | """ |
|
55 | """ | |
56 |
|
56 | |||
57 |
|
57 | |||
@@ -60,29 +60,28 b' def doctest_tb_context():' | |||||
60 | In [3]: xmode context |
|
60 | In [3]: xmode context | |
61 | Exception reporting mode: Context |
|
61 | Exception reporting mode: Context | |
62 |
|
62 | |||
63 | In [4]: run simpleerr.py |
|
63 | In [4]: run simpleerr.py | |
64 | --------------------------------------------------------------------------- |
|
64 | --------------------------------------------------------------------------- | |
65 | ZeroDivisionError Traceback (most recent call last) |
|
65 | ZeroDivisionError Traceback (most recent call last) | |
66 | <BLANKLINE> |
|
66 | <BLANKLINE> | |
67 | ... in <module> |
|
67 | ... in <module> | |
68 |
|
|
68 | 30 except IndexError: | |
69 |
3 |
|
69 | 31 mode = 'div' | |
70 |
---> 3 |
|
70 | ---> 33 bar(mode) | |
71 | <BLANKLINE> |
|
71 | <BLANKLINE> | |
72 | ... in bar(mode) |
|
72 | ... in bar(mode) | |
73 |
1 |
|
73 | 15 "bar" | |
74 |
1 |
|
74 | 16 if mode=='div': | |
75 |
---> 1 |
|
75 | ---> 17 div0() | |
76 |
1 |
|
76 | 18 elif mode=='exit': | |
77 |
1 |
|
77 | 19 try: | |
78 | <BLANKLINE> |
|
78 | <BLANKLINE> | |
79 | ... in div0() |
|
79 | ... in div0() | |
80 | 6 x = 1 |
|
80 | 6 x = 1 | |
81 | 7 y = 0 |
|
81 | 7 y = 0 | |
82 | ----> 8 x/y |
|
82 | ----> 8 x/y | |
83 | <BLANKLINE> |
|
83 | <BLANKLINE> | |
84 | ZeroDivisionError: ... |
|
84 | ZeroDivisionError: ...""" | |
85 | """ |
|
|||
86 |
|
85 | |||
87 |
|
86 | |||
88 | def doctest_tb_verbose(): |
|
87 | def doctest_tb_verbose(): | |
@@ -95,17 +94,17 b' def doctest_tb_verbose():' | |||||
95 | ZeroDivisionError Traceback (most recent call last) |
|
94 | ZeroDivisionError Traceback (most recent call last) | |
96 | <BLANKLINE> |
|
95 | <BLANKLINE> | |
97 | ... in <module> |
|
96 | ... in <module> | |
98 |
|
|
97 | 30 except IndexError: | |
99 |
3 |
|
98 | 31 mode = 'div' | |
100 |
---> 3 |
|
99 | ---> 33 bar(mode) | |
101 | mode = 'div' |
|
100 | mode = 'div' | |
102 | <BLANKLINE> |
|
101 | <BLANKLINE> | |
103 | ... in bar(mode='div') |
|
102 | ... in bar(mode='div') | |
104 |
1 |
|
103 | 15 "bar" | |
105 |
1 |
|
104 | 16 if mode=='div': | |
106 |
---> 1 |
|
105 | ---> 17 div0() | |
107 |
1 |
|
106 | 18 elif mode=='exit': | |
108 |
1 |
|
107 | 19 try: | |
109 | <BLANKLINE> |
|
108 | <BLANKLINE> | |
110 | ... in div0() |
|
109 | ... in div0() | |
111 | 6 x = 1 |
|
110 | 6 x = 1 | |
@@ -133,12 +132,14 b' def doctest_tb_sysexit():' | |||||
133 |
|
132 | |||
134 | In [20]: %tb |
|
133 | In [20]: %tb | |
135 | Traceback (most recent call last): |
|
134 | Traceback (most recent call last): | |
136 |
File ... |
|
135 | File ..., in execfile | |
|
136 | exec(compiler(f.read(), fname, 'exec'), glob, loc) | |||
|
137 | File ..., in <module> | |||
137 | bar(mode) |
|
138 | bar(mode) | |
138 |
File ... |
|
139 | File ..., in bar | |
139 | sysexit(stat, mode) |
|
140 | sysexit(stat, mode) | |
140 |
File ... |
|
141 | File ..., in sysexit | |
141 |
raise SystemExit(stat, f |
|
142 | raise SystemExit(stat, f"Mode = {mode}") | |
142 | SystemExit: (2, 'Mode = exit') |
|
143 | SystemExit: (2, 'Mode = exit') | |
143 |
|
144 | |||
144 | In [21]: %xmode context |
|
145 | In [21]: %xmode context | |
@@ -147,24 +148,39 b' def doctest_tb_sysexit():' | |||||
147 | In [22]: %tb |
|
148 | In [22]: %tb | |
148 | --------------------------------------------------------------------------- |
|
149 | --------------------------------------------------------------------------- | |
149 | SystemExit Traceback (most recent call last) |
|
150 | SystemExit Traceback (most recent call last) | |
150 | <BLANKLINE> |
|
151 | File ..., in execfile(fname, glob, loc, compiler) | |
|
152 | 70 with open(fname, 'rb') as f: | |||
|
153 | 71 compiler = compiler or compile | |||
|
154 | ---> 72 exec(compiler(f.read(), fname, 'exec'), glob, loc) | |||
151 | ...<module> |
|
155 | ...<module> | |
152 |
|
|
156 | 30 except IndexError: | |
153 |
3 |
|
157 | 31 mode = 'div' | |
154 |
---> 3 |
|
158 | ---> 33 bar(mode) | |
155 | <BLANKLINE> |
|
159 | <BLANKLINE> | |
156 | ...bar(mode) |
|
160 | ...bar(mode) | |
157 |
2 |
|
161 | 21 except: | |
158 |
2 |
|
162 | 22 stat = 1 | |
159 |
---> 2 |
|
163 | ---> 23 sysexit(stat, mode) | |
160 |
2 |
|
164 | 24 else: | |
161 |
2 |
|
165 | 25 raise ValueError('Unknown mode') | |
162 | <BLANKLINE> |
|
166 | <BLANKLINE> | |
163 | ...sysexit(stat, mode) |
|
167 | ...sysexit(stat, mode) | |
164 | 10 def sysexit(stat, mode): |
|
168 | 10 def sysexit(stat, mode): | |
165 |
---> 11 raise SystemExit(stat, f |
|
169 | ---> 11 raise SystemExit(stat, f"Mode = {mode}") | |
166 | <BLANKLINE> |
|
170 | <BLANKLINE> | |
167 | SystemExit: (2, 'Mode = exit') |
|
171 | SystemExit: (2, 'Mode = exit') | |
|
172 | """ | |||
|
173 | ||||
|
174 | ||||
|
175 | def doctest_tb_sysexit_verbose(): | |||
|
176 | """ | |||
|
177 | In [18]: %run simpleerr.py exit | |||
|
178 | An exception has occurred, use %tb to see the full traceback. | |||
|
179 | SystemExit: (1, 'Mode = exit') | |||
|
180 | ||||
|
181 | In [19]: %run simpleerr.py exit 2 | |||
|
182 | An exception has occurred, use %tb to see the full traceback. | |||
|
183 | SystemExit: (2, 'Mode = exit') | |||
168 |
|
184 | |||
169 | In [23]: %xmode verbose |
|
185 | In [23]: %xmode verbose | |
170 | Exception reporting mode: Verbose |
|
186 | Exception reporting mode: Verbose | |
@@ -174,23 +190,23 b' def doctest_tb_sysexit():' | |||||
174 | SystemExit Traceback (most recent call last) |
|
190 | SystemExit Traceback (most recent call last) | |
175 | <BLANKLINE> |
|
191 | <BLANKLINE> | |
176 | ... in <module> |
|
192 | ... in <module> | |
177 |
|
|
193 | 30 except IndexError: | |
178 |
3 |
|
194 | 31 mode = 'div' | |
179 |
---> 3 |
|
195 | ---> 33 bar(mode) | |
180 | mode = 'exit' |
|
196 | mode = 'exit' | |
181 | <BLANKLINE> |
|
197 | <BLANKLINE> | |
182 | ... in bar(mode='exit') |
|
198 | ... in bar(mode='exit') | |
183 |
|
|
199 | ... except: | |
184 |
|
|
200 | ... stat = 1 | |
185 |
---> |
|
201 | ---> ... sysexit(stat, mode) | |
186 | mode = 'exit' |
|
202 | mode = 'exit' | |
187 | stat = 2 |
|
203 | stat = 2 | |
188 |
|
|
204 | ... else: | |
189 |
|
|
205 | ... raise ValueError('Unknown mode') | |
190 | <BLANKLINE> |
|
206 | <BLANKLINE> | |
191 | ... in sysexit(stat=2, mode='exit') |
|
207 | ... in sysexit(stat=2, mode='exit') | |
192 | 10 def sysexit(stat, mode): |
|
208 | 10 def sysexit(stat, mode): | |
193 |
---> 11 raise SystemExit(stat, f |
|
209 | ---> 11 raise SystemExit(stat, f"Mode = {mode}") | |
194 | stat = 2 |
|
210 | stat = 2 | |
195 | <BLANKLINE> |
|
211 | <BLANKLINE> | |
196 | SystemExit: (2, 'Mode = exit') |
|
212 | SystemExit: (2, 'Mode = exit') |
General Comments 0
You need to be logged in to leave comments.
Login now