summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorJohn Belmonte <john@neggie.net>2022-07-11 06:40:53 (GMT)
committerGitHub <noreply@github.com>2022-07-11 06:40:53 (GMT)
commitda717519ecd17bf6c7ed334c12ff861f63b0f14f (patch)
tree582df2633e6f0e769a797bb496aea0944c58a111 /Doc
parentc9118afd045a64ca22d4a8cc5d43532607083b2d (diff)
downloadcpython-da717519ecd17bf6c7ed334c12ff861f63b0f14f.zip
cpython-da717519ecd17bf6c7ed334c12ff861f63b0f14f.tar.gz
cpython-da717519ecd17bf6c7ed334c12ff861f63b0f14f.tar.bz2
gh-93883: elide traceback indicators when possible (#93994)
* gh-93883: elide traceback indicators when possible Elide traceback column indicators when the entire line of the frame is implicated. This reduces traceback length and draws even more attention to the remaining (very relevant) indicators. Example: ``` Traceback (most recent call last): File "query.py", line 99, in <module> bar() File "query.py", line 66, in bar foo() File "query.py", line 37, in foo magic_arithmetic('foo') File "query.py", line 18, in magic_arithmetic return add_counts(x) / 25 ^^^^^^^^^^^^^ File "query.py", line 24, in add_counts return 25 + query_user(user1) + query_user(user2) ^^^^^^^^^^^^^^^^^ File "query.py", line 32, in query_user return 1 + query_count(db, response['a']['b']['c']['user'], retry=True) ~~~~~~~~~~~~~~~~~~^^^^^ TypeError: 'NoneType' object is not subscriptable ``` Rather than going out of our way to provide indicator coverage in every traceback test suite, the indicator test suite should be responible for sufficient coverage (e.g. by adding a basic exception group test to ensure that margin strings are covered).
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/traceback.rst13
-rw-r--r--Doc/whatsnew/3.11.rst1
2 files changed, 4 insertions, 10 deletions
diff --git a/Doc/library/traceback.rst b/Doc/library/traceback.rst
index 796309c..a8412cc 100644
--- a/Doc/library/traceback.rst
+++ b/Doc/library/traceback.rst
@@ -464,32 +464,27 @@ The output for the example would look similar to this:
*** print_tb:
File "<doctest...>", line 10, in <module>
lumberjack()
- ^^^^^^^^^^^^
*** print_exception:
Traceback (most recent call last):
File "<doctest...>", line 10, in <module>
lumberjack()
- ^^^^^^^^^^^^
File "<doctest...>", line 4, in lumberjack
bright_side_of_death()
- ^^^^^^^^^^^^^^^^^^^^^^
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()
- ^^^^^^^^^^^^^^^^^^^^^^
IndexError: tuple index out of range
*** format_exc, first and last line:
Traceback (most recent call last):
IndexError: tuple index out of range
*** format_exception:
['Traceback (most recent call last):\n',
- ' File "<doctest default[0]>", line 10, in <module>\n lumberjack()\n ^^^^^^^^^^^^\n',
- ' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_death()\n ^^^^^^^^^^^^^^^^^^^^^^\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 7, in bright_side_of_death\n return tuple()[0]\n ~~~~~~~^^^\n',
'IndexError: tuple index out of range\n']
*** extract_tb:
@@ -497,8 +492,8 @@ The output for the example would look similar to this:
<FrameSummary file <doctest...>, line 4 in lumberjack>,
<FrameSummary file <doctest...>, line 7 in bright_side_of_death>]
*** format_tb:
- [' File "<doctest default[0]>", line 10, in <module>\n lumberjack()\n ^^^^^^^^^^^^\n',
- ' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_death()\n ^^^^^^^^^^^^^^^^^^^^^^\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 7, in bright_side_of_death\n return tuple()[0]\n ~~~~~~~^^^\n']
*** tb_lineno: 10
diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index 9599152..f7274a8 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -117,7 +117,6 @@ when dealing with deeply nested dictionary objects and multiple function calls,
Traceback (most recent call last):
File "query.py", line 37, in <module>
magic_arithmetic('foo')
- ^^^^^^^^^^^^^^^^^^^^^^^
File "query.py", line 18, in magic_arithmetic
return add_counts(x) / 25
^^^^^^^^^^^^^