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

Skip to content

Commit 5caff8e

Browse files
authored
[doc] Update example in traceback doc (GH-96600) (GH-96605)
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)
1 parent eecbb54 commit 5caff8e

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
@@ -401,9 +401,9 @@ exception and traceback:
401401
import sys, traceback
402402

403403
def lumberjack():
404-
bright_side_of_death()
404+
bright_side_of_life()
405405

406-
def bright_side_of_death():
406+
def bright_side_of_life():
407407
return tuple()[0]
408408

409409
try:
@@ -413,19 +413,15 @@ exception and traceback:
413413
print("*** print_tb:")
414414
traceback.print_tb(exc_traceback, limit=1, file=sys.stdout)
415415
print("*** print_exception:")
416-
# exc_type below is ignored on 3.5 and later
417-
traceback.print_exception(exc_type, exc_value, exc_traceback,
418-
limit=2, file=sys.stdout)
416+
traceback.print_exception(exc_value, limit=2, file=sys.stdout)
419417
print("*** print_exc:")
420418
traceback.print_exc(limit=2, file=sys.stdout)
421419
print("*** format_exc, first and last line:")
422420
formatted_lines = traceback.format_exc().splitlines()
423421
print(formatted_lines[0])
424422
print(formatted_lines[-1])
425423
print("*** format_exception:")
426-
# exc_type below is ignored on 3.5 and later
427-
print(repr(traceback.format_exception(exc_type, exc_value,
428-
exc_traceback)))
424+
print(repr(traceback.format_exception(exc_value)))
429425
print("*** extract_tb:")
430426
print(repr(traceback.extract_tb(exc_traceback)))
431427
print("*** format_tb:")
@@ -445,32 +441,32 @@ The 8000 output for the example would look similar to this:
445441
File "<doctest...>", line 10, in <module>
446442
lumberjack()
447443
File "<doctest...>", line 4, in lumberjack
448-
bright_side_of_death()
444+
bright_side_of_life()
449445
IndexError: tuple index out of range
450446
*** print_exc:
451447
Traceback (most recent call last):
452448
File "<doctest...>", line 10, in <module>
453449
lumberjack()
454450
File "<doctest...>", line 4, in lumberjack
455-
bright_side_of_death()
451+
bright_side_of_life()
456452
IndexError: tuple index out of range
457453
*** format_exc, first and last line:
458454
Traceback (most recent call last):
459455
IndexError: tuple index out of range
460456
*** format_exception:
461457
['Traceback (most recent call last):\n',
462458
' File "<doctest...>", line 10, in <module>\n lumberjack()\n',
463-
' File "<doctest...>", line 4, in lumberjack\n bright_side_of_death()\n',
464-
' File "<doctest...>", line 7, in bright_side_of_death\n return tuple()[0]\n',
459+
' File "<doctest...>", line 4, in lumberjack\n bright_side_of_life()\n',
460+
' File "<doctest...>", line 7, in bright_side_of_life\n return tuple()[0]\n',
465461
'IndexError: tuple index out of range\n']
466462
*** extract_tb:
467463
[<FrameSummary file <doctest...>, line 10 in <module>>,
468464
<FrameSummary file <doctest...>, line 4 in lumberjack>,
469-
<FrameSummary file <doctest...>, line 7 in bright_side_of_death>]
465+
<FrameSummary file <doctest...>, line 7 in bright_side_of_life>]
470466
*** format_tb:
471467
[' File "<doctest...>", line 10, in <module>\n lumberjack()\n',
472-
' File "<doctest...>", line 4, in lumberjack\n bright_side_of_death()\n',
473-
' File "<doctest...>", line 7, in bright_side_of_death\n return tuple()[0]\n']
468+
' File "<doctest...>", line 4, in lumberjack\n bright_side_of_life()\n',
469+
' File "<doctest...>", line 7, in bright_side_of_life\n return tuple()[0]\n']
474470
*** tb_lineno: 10
475471

476472

0 commit comments

Comments
 (0)
0