8000 [doc] Update example in traceback doc (GH-96600) · python/cpython@c4999f2 · GitHub
[go: up one dir, main page]

Skip to content

Commit c4999f2

Browse files
authored
[doc] Update example in traceback doc (GH-96600)
This Monty Python reference is of-its-time. It could seem inappropriate in the context of today's sensibilities around mental health. Automerge-Triggered-By: GH:iritkatriel
1 parent 52fe7e5 commit c4999f2

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

Doc/library/traceback.rst

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,9 @@ exception and traceback:
429429
import sys, traceback
430430

431431
def lumberjack():
432-
bright_side_of_death()
432+
bright_side_of_life()
433433

434-
def bright_side_of_death():
434+
def bright_side_of_life():
435435
return tuple()[0]
436436

437437
try:
@@ -441,19 +441,15 @@ exception and traceback:
441441
print("*** print_tb:")
442442
traceback.print_tb(exc_traceback, limit=1, file=sys.stdout)
443443
print("*** print_exception:")
444-
# exc_type below is ignored on 3.5 and later
445-
traceback.print_exception(exc_type, exc_value, exc_traceback,
446-
limit=2, file=sys.stdout)
444+
traceback.print_exception(exc_value, limit=2, file=sys.stdout)
447445
print("*** print_exc:")
448446
traceback.print_exc(limit=2, file=sys.stdout)
449447
print("*** format_exc, first and last line:")
450448
formatted_lines = traceback.format_exc().splitlines()
451449
print(formatted_lines[0])
452450
print(formatted_lines[-1])
453451
print("*** format_exception:")
454-
# exc_type below is ignored on 3.5 and later
455-
print(repr(traceback.format_exception(exc_type, exc_value,
456-
exc_traceback)))
452+
print(repr(traceback.format_exception(exc_value)))
457453
print("*** extract_tb:")
458454
print(repr(traceback.extract_tb(exc_traceback)))
459455
print("*** format_tb:")
@@ -473,32 +469,32 @@ The output for the example would look similar to this:
473469
File "<doctest...>", line 10, in <module>
474470
lumberjack()
475471
File "<doctest...>", line 4, in lumberjack
476-
bright_side_of_death()
472+
bright_side_of_life()
477473
IndexError: tuple index out of range
478474
*** print_exc:
479475
Traceback (most recent call last):
480476
File "<doctest...>", line 10, in <module>
481477
lumberjack()
482478
File "<doctest...>", line 4, in lumberjack
483-
bright_side_of_death()
479+
bright_side_of_life()
484480
IndexError: tuple index out of range
485481
*** format_exc, first and last line:
486482
Traceback (most recent call last):
487483
IndexError: tuple index out of range
488484
*** format_exception:
489485
['Traceback (most recent call last):\n',
490486
' File "<doctest default[0]>", line 10, in <module>\n lumberjack()\n',
491-
' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_death()\n',
492-
' File "<doctest default[0]>", line 7, in bright_side_of_death\n return tuple()[0]\n ~~~~~~~^^^\n',
487+
' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_life()\n',
488+
' File "<doctest default[0]>", line 7, in bright_side_of_life\n return tuple()[0]\n ~~~~~~~^^^\n',
493489
'IndexError: tuple index out of range\n']
494490
*** extract_tb:
495491
[<FrameSummary file <doctest...>, line 10 in <module>>,
496492
<FrameSummary file <doctest...>, line 4 in lumberjack>,
497-
<FrameSummary file <doctest...>, line 7 in bright_side_of_death>]
493+
<FrameSummary file <doctest...>, line 7 in bright_side_of_life>]
498494
*** format_tb:
499495
[' File "<doctest default[0]>", line 10, in <module>\n lumberjack()\n',
500-
' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_death()\n',
501-
' File "<doctest default[0]>", line 7, in bright_side_of_death\n return tuple()[0]\n ~~~~~~~^^^\n']
496+
' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_life()\n',
497+
' File "<doctest default[0]>", line 7, in bright_side_of_life\n return tuple()[0]\n ~~~~~~~^^^\n']
502498
*** tb_lineno: 10
503499

504500

0 commit comments

Comments
 (0)
0