Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a5a9d05

Browse files
authored
[3.11] [doc] Update example in traceback doc (GH-96600) (GH-96603)
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 (cherry picked from commit c4999f2) Co-authored-by: Irit Katriel <[email protected]>
1 parent c612cc2 commit a5a9d05

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
@@ -425,9 +425,9 @@ exception and traceback:
425425
import sys, traceback
426426

427427
def lumberjack():
428-
bright_side_of_death()
428+
bright_side_of_life()
429429

430-
def bright_side_of_death():
430+
def bright_side_of_life():
431431
return tuple()[0]
432432

433433
try:
@@ -437,19 +437,15 @@ exception and traceback:
437437
print("*** print_tb:")
438438
traceback.print_tb(exc_traceback, limit=1, file=sys.stdout)
439439
print("*** print_exception:")
440-
# exc_type below is ignored on 3.5 and later
441-
traceback.print_exception(exc_type, exc_value, exc_traceback,
442-
limit=2, file=sys.stdout)
440+
traceback.print_exception(exc_value, limit=2, file=sys.stdout)
443441
print("*** print_exc:")
444442
traceback.print_exc(limit=2, file=sys.stdout)
445443
print("*** format_exc, first and last line:")
446444
formatted_lines = traceback.format_exc().splitlines()
447445
print(formatted_lines[0])
448446
print(formatted_lines[-1])
449447
print("*** format_exception:")
450-
# exc_type below is ignored on 3.5 and later
451-
print(repr(traceback.format_exception(exc_type, exc_value,
452-
exc_traceback)))
448+
print(repr(traceback.format_exception(exc_value)))
453449
print("*** extract_tb:")
454450
print(repr(traceback.extract_tb(exc_traceback)))
455451
print("*** format_tb:")
@@ -469,32 +465,32 @@ The output for the example would look similar to this:
469465
File "<doctest...>", line 10, in <module>
470466
lumberjack()
471467
File "<doctest...>", line 4, in lumberjack
472-
bright_side_of_death()
468+
bright_side_of_life()
473469
IndexError: tuple index out of range
474470
*** print_exc:
475471
Traceback (most recent call last):
476472
File "<doctest...>", line 10, in <module>
477473
lumberjack()
478474
File "<doctest...>", line 4, in lumberjack
479-
bright_side_of_death()
475+
bright_side_of_life()
480476
IndexError: tuple index out of range
481477
*** format_exc, first and last line:
482478
Traceback (most recent call last):
483479
IndexError: tuple index out of range
484480
*** format_exception:
485481
['Traceback (most recent call last):\n',
486482
' File "<doctest default[0]>", line 10, in <module>\n lumberjack()\n',
487-
' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_death()\n',
488-
' File "<doctest default[0]>", line 7, in bright_side_of_death\n return tuple()[0]\n ~~~~~~~^^^\n',
483+
' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_life()\n',
484+
' File "<doctest default[0]>", line 7, in bright_side_of_life\n return tuple()[0]\n ~~~~~~~^^^\n',
489485
'IndexError: tuple index out of range\n']
490486
*** extract_tb:
491487
[<FrameSummary file <doctest...>, line 10 in <module>>,
492488
<FrameSummary file <doctest...>, line 4 in lumberjack>,
493-
<FrameSummary file <doctest...>, line 7 in bright_side_of_death>]
489+
<FrameSummary file <doctest...>, line 7 in bright_side_of_life>]
494490
*** format_tb:
495491
[' File "<doctest default[0]>", line 10, in <module>\n lumberjack()\n',
496-
' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_death()\n',
497-
' File "<doctest default[0]>", line 7, in bright_side_of_death\n return tuple()[0]\n ~~~~~~~^^^\n']
492+
' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_life()\n',
493+
' File "<doctest default[0]>", line 7, in bright_side_of_life\n return tuple()[0]\n ~~~~~~~^^^\n']
498494
*** tb_lineno: 10
499495

500496

0 commit comments

Comments
 (0)