@@ -52,7 +52,7 @@ The module's API can be divided into two parts:
52
52
Module-Level Functions
53
53
----------------------
54
54
55
- .. function :: print_tb(tb, limit=None, file=None, *, show_lines =True, recent_first=False)
55
+ .. function :: print_tb(tb, limit=None, file=None, *, show_source_lines =True, recent_first=False)
56
56
57
57
Print up to *limit * stack trace entries from
58
58
:ref: `traceback object <traceback-objects >` *tb * (starting
@@ -63,7 +63,8 @@ Module-Level Functions
63
63
:term: `file <file object> ` or :term: `file-like object ` to
64
64
receive the output.
65
65
66
- If *show_lines * is true (the default), source code lines will be included in the output.
66
+ If *show_source_lines * is true (the default), source code lines
67
+ will be included in the output.
67
68
68
69
If *recent_first * is true, the most recent stack trace entries are printed
69
70
first, otherwise the oldest entries are printed first. The default is false.
@@ -85,11 +86,12 @@ Module-Level Functions
85
86
Added negative *limit * support.
86
87
87
88
.. versionchanged :: next
88
- Added the *show_lines * and *recent_first * parameters.
89
+ Added the *show_source_lines * and *recent_first * parameters.
89
90
90
91
91
92
.. function :: print_exception(exc, /[, value, tb], limit=None, \
92
- file=None, chain=True, *, show_lines=True, recent_first=False)
93
+ file=None, chain=True, *, \
94
+ show_source_lines=True, recent_first=False)
93
95
94
96
Print exception information and stack trace entries from
95
97
:ref: `traceback object <traceback-objects >`
@@ -118,7 +120,7 @@ Module-Level Functions
118
120
printed as well, like the interpreter itself does when printing an unhandled
119
121
exception.
120
122
121
- If *show_lines * is true, source code lines are included in the output.
123
+ If *show_source_lines * is true, source code lines are included in the output.
122
124
123
125
If *recent_first * is true, the most recent stack trace entries are printed
124
126
first, otherwise the oldest entries are printed first. The default is false.
@@ -131,45 +133,45 @@ Module-Level Functions
131
133
positional-only.
132
134
133
135
.. versionchanged :: next
134
- Added the *show_lines * and *recent_first * parameters.
136
+ Added the *show_source_lines * and *recent_first * parameters.
135
137
136
138
137
- .. function :: print_exc(limit=None, file=None, chain=True, *, show_lines =True, recent_first=False)
139
+ .. function :: print_exc(limit=None, file=None, chain=True, *, show_source_lines =True, recent_first=False)
138
140
139
141
This is a shorthand for ``print_exception(sys.exception(), limit=limit, file=file,
140
- chain=chain, show_lines=show_lines , recent_first=recent_first) ``.
142
+ chain=chain, show_source_lines=show_source_lines , recent_first=recent_first) ``.
141
143
142
144
.. versionchanged :: next
143
- Added the *show_lines * and *recent_first * parameters.
145
+ Added the *show_source_lines * and *recent_first * parameters.
144
146
145
147
146
- .. function :: print_last(limit=None, file=None, chain=True, *, show_lines =True, recent_first=False)
148
+ .. function :: print_last(limit=None, file=None, chain=True, *, show_source_lines =True, recent_first=False)
147
149
148
150
This is a shorthand for ``print_exception(sys.last_exc, limit=limit, file=file,
149
- chain=chain, show_lines=show_lines , recent_first=recent_first) ``.
151
+ chain=chain, show_source_lines=show_source_lines , recent_first=recent_first) ``.
150
152
In general it will work only after an exception has reached an interactive
151
153
prompt (see :data: `sys.last_exc `).
152
154
153
155
.. versionchanged :: next
154
- Added the *show_lines * and *recent_first * parameters.
156
+ Added the *show_source_lines * and *recent_first * parameters.
155
157
156
158
157
- .. function :: print_stack(f=None, limit=None, file=None, *, show_lines =True, recent_first=False)
159
+ .. function :: print_stack(f=None, limit=None, file=None, *, show_source_lines =True, recent_first=False)
158
160
159
161
Print up to *limit * stack trace entries (starting from the invocation
160
162
point) if *limit * is positive. Otherwise, print the last ``abs(limit) ``
161
163
entries. If *limit * is omitted or ``None ``, all entries are printed.
162
164
The optional *f * argument can be used to specify an alternate
163
165
:ref: `stack frame <frame-objects >`
164
166
to start. The optional *file * argument has the same meaning as for
165
- :func: `print_tb `. If * show_lines * is true, source code lines are
166
- included in the output.
167
+ :func: `print_tb `.
168
+ If * show_source_lines * is true, source code lines are included in the output.
167
169
168
170
.. versionchanged :: 3.5
169
171
Added negative *limit * support.
170
172
171
173
.. versionchanged :: next
172
- Added the *show_lines * and *recent_first * parameters.
174
+ Added the *show_source_lines * and *recent_first * parameters.
173
175
174
176
175
177
.. function :: extract_tb(tb, limit=None)
@@ -193,29 +195,29 @@ Module-Level Functions
193
195
arguments have the same meaning as for :func: `print_stack `.
194
196
195
197
196
- .. function :: print_list(extracted_list, file=None, *, show_lines =True)
198
+ .. function :: print_list(extracted_list, file=None, *, show_source_lines =True)
197
199
198
200
Print the list of tuples as returned by :func: `extract_tb ` or
199
201
:func: `extract_stack ` as a formatted stack trace to the given file.
200
202
If *file * is ``None ``, the output is written to :data: `sys.stderr `.
201
- If *show_lines * is true, source code lines are included in the output.
203
+ If *show_source_lines * is true, source code lines are included in the output.
202
204
203
205
.. versionchanged :: next
204
- Added the *show_lines * parameter.
206
+ Added the *show_source_lines * parameter.
205
207
206
208
207
- .. function :: format_list(extracted_list, *, show_lines =True)
209
+ .. function :: format_list(extracted_list, *, show_source_lines =True)
208
210
209
211
Given a list of tuples or :class: `FrameSummary ` objects as returned by
210
212
:func: `extract_tb ` or :func: `extract_stack `, return a list of strings ready
211
213
for printing. Each string in the resulting list corresponds to the item with
212
214
the same index in the argument list. Each string ends in a newline; the
213
215
strings may contain internal newlines as well, for those items whose source
214
- text line is not ``None ``. If * show_lines * is `` True ``, source code lines
215
- are included in the output.
216
+ text line is not ``None ``.
217
+ If * show_source_lines * is true, source code lines are included in the output.
216
218
217
219
.. versionchanged :: next
218
- Added the *show_lines * parameter.
220
+ Added the *show_source_lines * parameter.
219
221
220
222
221
223
.. function :: format_exception_only(exc, /[, value], *, show_group=False)
@@ -248,15 +250,16 @@ Module-Level Functions
248
250
*show_group * parameter was added.
249
251
250
252
251
- .. function :: format_exception(exc, /[, value, tb], limit=None, chain=True, *, show_lines=True, recent_first=False, show_group=False)
253
+ .. function :: format_exception(exc, /[, value, tb], limit=None, chain=True, *, \
254
+ show_source_lines=True, recent_first=False)
252
255
253
256
Format a stack trace and the exception information. The arguments have the
254
257
same meaning as the corresponding arguments to :func: `print_exception `. The
255
258
return value is a list of strings, each ending in a newline and some
256
259
containing internal newlines. When these lines are concatenated and printed,
257
260
exactly the same text is printed as does :func: `print_exception `.
258
261
259
- If *show_lines * is true, source code lines are included in the output.
262
+ If *show_source_lines * is true, source code lines are included in the output.
260
263
If *recent_first * is true, the most recent stack trace entries are printed
261
264
first, otherwise the oldest entries are printed first. The default is false.
262
265
@@ -268,40 +271,40 @@ Module-Level Functions
268
271
:func: `print_exception `.
269
272
270
273
.. versionchanged :: next
271
- Added the *show_lines * and *recent_first * parameters.
274
+ Added the *show_source_lines * and *recent_first * parameters.
272
275
273
276
274
- .. function :: format_exc(limit=None, chain=True, *, show_lines =True, recent_first=False)
277
+ .. function :: format_exc(limit=None, chain=True, *, show_source_lines =True, recent_first=False)
275
278
276
279
This is like ``print_exc(limit) `` but returns a string instead of printing to
277
280
a file.
278
281
279
- If *show_lines * is true, source code lines are included in the output.
282
+ If *show_source_lines * is true, source code lines are included in the output.
280
283
If *recent_first * is true, the most recent stack trace entries are printed
281
284
first, otherwise the oldest entries are printed first. The default is false.
282
285
283
286
.. versionchanged :: next
284
- Added the *show_lines * and *recent_first * parameters.
287
+ Added the *show_source_lines * and *recent_first * parameters.
285
288
286
289
287
- .. function :: format_tb(tb, limit=None, *, show_lines =True, recent_first=False)
290
+ .. function :: format_tb(tb, limit=None, *, show_source_lines =True, recent_first=False)
288
291
289
- A shorthand for ``format_list(extract_tb(tb, limit), show_lines=show_lines ) ``.
292
+ A shorthand for ``format_list(extract_tb(tb, limit), show_source_lines=show_source_lines ) ``.
290
293
291
294
If *recent_first * is true, ``reversed(extract_tb(tb, limit)) `` is used.
292
295
293
296
.. versionchanged :: next
294
- Added the *show_lines * and *recent_first * parameters.
297
+ Added the *show_source_lines * and *recent_first * parameters.
295
298
296
299
297
- .. function :: format_stack(f=None, limit=None, *, show_lines =True, recent_first=False)
300
+ .. function :: format_stack(f=None, limit=None, *, show_source_lines =True, recent_first=False)
298
301
299
- A shorthand for ``format_list(extract_stack(f, limit), show_lines=show_lines ) ``.
302
+ A shorthand for ``format_list(extract_stack(f, limit), show_source_lines=show_source_lines ) ``.
300
303
301
304
If *recent_first * is true, ``reversed(extract_stack(f, limit)) `` is used.
302
305
303
306
.. versionchanged :: next
304
- Added the *show_lines * and *recent_first * parameters.
307
+ Added the *show_source_lines * and *recent_first * parameters.
305
308
306
309
.. function :: clear_frames(tb)
307
310
@@ -347,7 +350,8 @@ storing this information by avoiding holding references to
347
350
In addition, they expose more options to configure the output compared to
348
351
the module-level functions described above.
349
352
350
- .. class :: TracebackException(exc_type, exc_value, exc_traceback, *, limit=None, lookup_lines=False, capture_locals=False, compact=False, max_group_width=15, max_group_depth=10)
353
+ .. class :: TracebackException(exc_type, exc_value, exc_traceback, *, limit=None, lookup_lines=False, \
354
+ capture_locals=False, compact=False, max_group_width=15, max_group_depth=10)
351
355
352
356
Capture an exception for later rendering. The meaning of *limit *,
353
357
*lookup_lines * and *capture_locals * are as for the :class: `StackSummary `
@@ -375,7 +379,7 @@ the module-level functions described above.
375
379
376
380
.. versionchanged :: next
377
381
Changed *lookup_lines * default to ``False `` to avoid overhead when
378
- formatting exceptions with ``show_lines =False ``.
382
+ formatting exceptions with ``show_source_lines =False ``.
379
383
380
384
.. attribute :: __cause__
381
385
@@ -468,14 +472,14 @@ the module-level functions described above.
468
472
469
473
.. versionchanged :: next
470
474
Changed *lookup_lines * default to ``False `` to avoid overhead when
471
- formatting exceptions with ``show_lines =False ``.
475
+ formatting exceptions with ``show_source_lines =False ``.
472
476
473
- .. method :: print(*, file=None, chain=True, show_lines =True, recent_first=False)
477
+ .. method :: print(*, file=None, chain=True, show_source_lines =True, recent_first=False)
474
478
475
479
Print to *file * (default ``sys.stderr ``) the exception information returned by
476
480
:meth: `format `.
477
481
478
- If *show_lines * is true, source code lines are included in the output.
482
+ If *show_source_lines * is true, source code lines are included in the output.
479
483
480
484
If *recent_first * is true, the exception is printed first followed by stack
481
485
trace by "most recent call first" order.
@@ -485,9 +489,9 @@ the module-level functions described above.
485
489
.. versionadded :: 3.11
486
490
487
491
.. versionchanged :: next
488
- Added the *show_lines * and *recent_first * parameters.
492
+ Added the *show_source_lines * and *recent_first * parameters.
489
493
490
- .. method :: format(*, chain=True, show_lines =True, recent_first=False)
494
+ .. method :: format(*, chain=True, show_source_lines =True, recent_first=False)
491
495
492
496
Format the exception.
493
497
@@ -498,17 +502,17 @@ the module-level functions described above.
498
502
some containing internal newlines. :func: `~traceback.print_exception `
499
503
is a wrapper around this method which just prints the lines to a file.
500
504
501
- If *show_lines * is true, source code lines are included in the output.
505
+ If *show_source_lines * is true, source code lines are included in the output.
502
506
503
507
If *recent_first * is true, the exception is printed first followed by stack
504
508
trace by "most recent call first" order.
505
509
Otherwise, the stack trace is printed first by "most recent call last" order
506
510
followed by the exception.
507
511
508
512
.. versionchanged :: next
509
- Added the *show_lines * and *recent_first * parameters.
513
+ Added the *show_source_lines * and *recent_first * parameters.
510
514
511
- .. method :: format_exception_only(*, show_group=False)
515
+ .. method :: format_exception_only(*, show_group=False)
512
516
513
517
Format the exception part of the traceback.
514
518
@@ -561,7 +565,7 @@ the module-level functions described above.
561
565
562
566
.. versionchanged :: next
563
567
Changed *lookup_lines * default to ``False `` to avoid overhead when
564
- formatting traceback with ``show_lines =False ``.
568
+ formatting traceback with ``show_source_lines =False ``.
565
569
566
570
.. classmethod :: from_list(a_list)
567
571
@@ -570,7 +574,7 @@ the module-level functions described above.
570
574
should be a 4-tuple with *filename *, *lineno *, *name *, *line * as the
571
575
elements.
572
576
573
- .. method :: format(*, show_lines =True)
577
+ .. method :: format(*, show_source_lines =True)
574
578
575
579
Returns a list of strings ready for printing. Each string in the
576
580
resulting list corresponds to a single :ref: `frame <frame-objects >` from
@@ -582,29 +586,28 @@ the module-level functions described above.
582
586
repetitions are shown, followed by a summary line stating the exact
583
587
number of further repetitions.
584
588
585
- If *show_lines * is true, includes source code lines in the output.
589
+ If *show_source_lines * is true, includes source code lines in the output.
586
590
587
591
.. versionchanged :: 3.6
588
592
Long sequences of repeated frames are now abbreviated.
589
593
590
594
.. versionchanged :: next
591
- Added the *show_lines * parameter.
595
+ Added the *show_source_lines * parameter.
592
596
593
- .. method :: format_frame_summary(frame_summary, *, show_lines =True, **kwargs)
597
+ .. method :: format_frame_summary(frame_summary, *, show_source_lines =True, **kwargs)
594
598
595
599
Returns a string for printing one of the :ref: `frames <frame-objects >`
596
600
involved in the stack.
597
601
This method is called for each :class: `FrameSummary ` object to be
598
602
printed by :meth: `StackSummary.format `. If it returns ``None ``, the
599
603
frame is omitted from the output.
600
604
601
- The keyword argument *show_lines *, if ``True ``, includes source code
602
- lines in the output.
605
+ If *show_source_lines * is true, includes source code lines in the output.
603
606
604
607
.. versionadded :: 3.11
605
608
606
609
.. versionchanged :: next
607
- Added the *show_lines * parameter.
610
+ Added the *show_source_lines * parameter.
608
611
609
612
610
613
:class: `!FrameSummary ` Objects
0 commit comments