MCPcopy Create free account
hub / github.com/ipython/ipython / doctest_tb_sysexit

Function doctest_tb_sysexit

IPython/core/tests/test_iplib.py:126–212  ·  view source on GitHub ↗

In [17]: %xmode plain Exception reporting mode: Plain In [18]: %run simpleerr.py exit An exception has occurred, use %tb to see the full traceback. SystemExit: (1, 'Mode = exit') In [19]: %run simpleerr.py exit 2 An exception has occurred, use %tb to see the full traceback. SystemExit: (2, 'Mode

()

Source from the content-addressed store, hash-verified

124 """
125
126def doctest_tb_sysexit():
127 """
128In [17]: %xmode plain
129Exception reporting mode: Plain
130
131In [18]: %run simpleerr.py exit
132An exception has occurred, use %tb to see the full traceback.
133SystemExit: (1, 'Mode = exit')
134
135In [19]: %run simpleerr.py exit 2
136An exception has occurred, use %tb to see the full traceback.
137SystemExit: (2, 'Mode = exit')
138
139In [20]: %tb
140Traceback (most recent call last):
141 File ... in <module>
142 bar(mode)
143 File ... line 22, in bar
144 sysexit(stat, mode)
145 File ... line 11, in sysexit
146 raise SystemExit(stat, 'Mode = %s' % mode)
147SystemExit: (2, 'Mode = exit')
148
149In [21]: %xmode context
150Exception reporting mode: Context
151
152In [22]: %tb
153---------------------------------------------------------------------------
154SystemExit Traceback (most recent call last)
155<BLANKLINE>
156...<module>
157 30 mode = 'div'
158 31
159---> 32 bar(mode)
160<BLANKLINE>
161...bar(mode)
162 20 except:
163 21 stat = 1
164---> 22 sysexit(stat, mode)
165 23 else:
166 24 raise ValueError('Unknown mode')
167<BLANKLINE>
168...sysexit(stat, mode)
169 9
170 10 def sysexit(stat, mode):
171---> 11 raise SystemExit(stat, 'Mode = %s' % mode)
172 12
173 13 def bar(mode):
174<BLANKLINE>
175SystemExit: (2, 'Mode = exit')
176
177In [23]: %xmode verbose
178Exception reporting mode: Verbose
179
180In [24]: %tb
181---------------------------------------------------------------------------
182SystemExit Traceback (most recent call last)
183<BLANKLINE>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected