[Python-checkins] [doc] Update example in traceback doc (GH-96600) (GH-96605)
iritkatriel
webhook-mailer at python.org
Wed Sep 7 07:56:30 EDT 2022
https://github.com/python/cpython/commit/5caff8ec38c4687bce5f53d6ed427971827d0927
commit: 5caff8ec38c4687bce5f53d6ed427971827d0927
branch: 3.10
author: Irit Katriel <1055913+iritkatriel at users.noreply.github.com>
committer: iritkatriel <1055913+iritkatriel at users.noreply.github.com>
date: 2022-09-07T12:56:25+01:00
summary:
[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 c4999f261fb0cb28ef713b48ef2e81ca5a3eb1e1)
files:
M Doc/library/traceback.rst
diff --git a/Doc/library/traceback.rst b/Doc/library/traceback.rst
index e938dd58b053..c93e7f49c110 100644
--- a/Doc/library/traceback.rst
+++ b/Doc/library/traceback.rst
@@ -401,9 +401,9 @@ exception and traceback:
import sys, traceback
def lumberjack():
- bright_side_of_death()
+ bright_side_of_life()
- def bright_side_of_death():
+ def bright_side_of_life():
return tuple()[0]
try:
@@ -413,9 +413,7 @@ exception and traceback:
print("*** print_tb:")
traceback.print_tb(exc_traceback, limit=1, file=sys.stdout)
print("*** print_exception:")
- # exc_type below is ignored on 3.5 and later
- traceback.print_exception(exc_type, exc_value, exc_traceback,
- limit=2, file=sys.stdout)
+ traceback.print_exception(exc_value, limit=2, file=sys.stdout)
print("*** print_exc:")
traceback.print_exc(limit=2, file=sys.stdout)
print("*** format_exc, first and last line:")
@@ -423,9 +421,7 @@ exception and traceback:
print(formatted_lines[0])
print(formatted_lines[-1])
print("*** format_exception:")
- # exc_type below is ignored on 3.5 and later
- print(repr(traceback.format_exception(exc_type, exc_value,
- exc_traceback)))
+ print(repr(traceback.format_exception(exc_value)))
print("*** extract_tb:")
print(repr(traceback.extract_tb(exc_traceback)))
print("*** format_tb:")
@@ -445,14 +441,14 @@ The output for the example would look similar to this:
File "<doctest...>", line 10, in <module>
lumberjack()
File "<doctest...>", line 4, in lumberjack
- bright_side_of_death()
+ bright_side_of_life()
IndexError: tuple index out of range
*** print_exc:
Traceback (most recent call last):
File "<doctest...>", line 10, in <module>
lumberjack()
File "<doctest...>", line 4, in lumberjack
- bright_side_of_death()
+ bright_side_of_life()
IndexError: tuple index out of range
*** format_exc, first and last line:
Traceback (most recent call last):
@@ -460,17 +456,17 @@ The output for the example would look similar to this:
*** format_exception:
['Traceback (most recent call last):\n',
' File "<doctest...>", line 10, in <module>\n lumberjack()\n',
- ' File "<doctest...>", line 4, in lumberjack\n bright_side_of_death()\n',
- ' File "<doctest...>", line 7, in bright_side_of_death\n return tuple()[0]\n',
+ ' File "<doctest...>", line 4, in lumberjack\n bright_side_of_life()\n',
+ ' File "<doctest...>", line 7, in bright_side_of_life\n return tuple()[0]\n',
'IndexError: tuple index out of range\n']
*** extract_tb:
[<FrameSummary file <doctest...>, line 10 in <module>>,
<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:
[' File "<doctest...>", line 10, in <module>\n lumberjack()\n',
- ' File "<doctest...>", line 4, in lumberjack\n bright_side_of_death()\n',
- ' File "<doctest...>", line 7, in bright_side_of_death\n return tuple()[0]\n']
+ ' File "<doctest...>", line 4, in lumberjack\n bright_side_of_life()\n',
+ ' File "<doctest...>", line 7, in bright_side_of_life\n return tuple()[0]\n']
*** tb_lineno: 10
More information about the Python-checkins
mailing list