Skip to content
Snippets Groups Projects
Unverified Commit a5a9d051 authored by Irit Katriel's avatar Irit Katriel Committed by GitHub
Browse files

[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 c4999f26)

Co-authored-by: default avatarIrit Katriel <1055913+iritkatriel@users.noreply.github.com>
parent c612cc2b
Branches
Tags
No related merge requests found
...@@ -425,9 +425,9 @@ exception and traceback: ...@@ -425,9 +425,9 @@ exception and traceback:
import sys, traceback import sys, traceback
def lumberjack(): def lumberjack():
bright_side_of_death() bright_side_of_life()
def bright_side_of_death(): def bright_side_of_life():
return tuple()[0] return tuple()[0]
try: try:
...@@ -437,9 +437,7 @@ exception and traceback: ...@@ -437,9 +437,7 @@ exception and traceback:
print("*** print_tb:") print("*** print_tb:")
traceback.print_tb(exc_traceback, limit=1, file=sys.stdout) traceback.print_tb(exc_traceback, limit=1, file=sys.stdout)
print("*** print_exception:") print("*** print_exception:")
# exc_type below is ignored on 3.5 and later traceback.print_exception(exc_value, limit=2, file=sys.stdout)
traceback.print_exception(exc_type, exc_value, exc_traceback,
limit=2, file=sys.stdout)
print("*** print_exc:") print("*** print_exc:")
traceback.print_exc(limit=2, file=sys.stdout) traceback.print_exc(limit=2, file=sys.stdout)
print("*** format_exc, first and last line:") print("*** format_exc, first and last line:")
...@@ -447,9 +445,7 @@ exception and traceback: ...@@ -447,9 +445,7 @@ exception and traceback:
print(formatted_lines[0]) print(formatted_lines[0])
print(formatted_lines[-1]) print(formatted_lines[-1])
print("*** format_exception:") print("*** format_exception:")
# exc_type below is ignored on 3.5 and later print(repr(traceback.format_exception(exc_value)))
print(repr(traceback.format_exception(exc_type, exc_value,
exc_traceback)))
print("*** extract_tb:") print("*** extract_tb:")
print(repr(traceback.extract_tb(exc_traceback))) print(repr(traceback.extract_tb(exc_traceback)))
print("*** format_tb:") print("*** format_tb:")
...@@ -469,14 +465,14 @@ The output for the example would look similar to this: ...@@ -469,14 +465,14 @@ The output for the example would look similar to this:
File "<doctest...>", line 10, in <module> File "<doctest...>", line 10, in <module>
lumberjack() lumberjack()
File "<doctest...>", line 4, in lumberjack File "<doctest...>", line 4, in lumberjack
bright_side_of_death() bright_side_of_life()
IndexError: tuple index out of range IndexError: tuple index out of range
*** print_exc: *** print_exc:
Traceback (most recent call last): Traceback (most recent call last):
File "<doctest...>", line 10, in <module> File "<doctest...>", line 10, in <module>
lumberjack() lumberjack()
File "<doctest...>", line 4, in lumberjack File "<doctest...>", line 4, in lumberjack
bright_side_of_death() bright_side_of_life()
IndexError: tuple index out of range IndexError: tuple index out of range
*** format_exc, first and last line: *** format_exc, first and last line:
Traceback (most recent call last): Traceback (most recent call last):
...@@ -484,17 +480,17 @@ The output for the example would look similar to this: ...@@ -484,17 +480,17 @@ The output for the example would look similar to this:
*** format_exception: *** format_exception:
['Traceback (most recent call last):\n', ['Traceback (most recent call last):\n',
' File "<doctest default[0]>", line 10, in <module>\n lumberjack()\n', ' File "<doctest default[0]>", line 10, in <module>\n lumberjack()\n',
' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_death()\n', ' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_life()\n',
' File "<doctest default[0]>", line 7, in bright_side_of_death\n return tuple()[0]\n ~~~~~~~^^^\n', ' File "<doctest default[0]>", line 7, in bright_side_of_life\n return tuple()[0]\n ~~~~~~~^^^\n',
'IndexError: tuple index out of range\n'] 'IndexError: tuple index out of range\n']
*** extract_tb: *** extract_tb:
[<FrameSummary file <doctest...>, line 10 in <module>>, [<FrameSummary file <doctest...>, line 10 in <module>>,
<FrameSummary file <doctest...>, line 4 in lumberjack>, <FrameSummary file <doctest...>, line 4 in lumberjack>,
<FrameSummary file <doctest...>, line 7 in bright_side_of_death>] <FrameSummary file <doctest...>, line 7 in bright_side_of_life>]
*** format_tb: *** format_tb:
[' File "<doctest default[0]>", line 10, in <module>\n lumberjack()\n', [' File "<doctest default[0]>", line 10, in <module>\n lumberjack()\n',
' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_death()\n', ' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_life()\n',
' File "<doctest default[0]>", line 7, in bright_side_of_death\n return tuple()[0]\n ~~~~~~~^^^\n'] ' File "<doctest default[0]>", line 7, in bright_side_of_life\n return tuple()[0]\n ~~~~~~~^^^\n']
*** tb_lineno: 10 *** tb_lineno: 10
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment