]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-93883: elide traceback indicators when possible (#93994)
authorJohn Belmonte <john@neggie.net>
Mon, 11 Jul 2022 06:40:53 +0000 (15:40 +0900)
committerGitHub <noreply@github.com>
Mon, 11 Jul 2022 06:40:53 +0000 (07:40 +0100)
commitda717519ecd17bf6c7ed334c12ff861f63b0f14f
tree582df2633e6f0e769a797bb496aea0944c58a111
parentc9118afd045a64ca22d4a8cc5d43532607083b2d
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).
Doc/library/traceback.rst
Doc/whatsnew/3.11.rst
Lib/idlelib/idle_test/test_run.py
Lib/test/test_cmd_line_script.py
Lib/test/test_doctest.py
Lib/test/test_traceback.py
Lib/traceback.py
Misc/NEWS.d/next/Core and Builtins/2022-06-24-14-06-20.gh-issue-93883.8jVQQ4.rst [new file with mode: 0644]
Python/traceback.c