mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
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).
This commit is contained in:
parent
c9118afd04
commit
da717519ec
9 changed files with 111 additions and 135 deletions
|
@ -2854,7 +2854,7 @@ except UnicodeEncodeError:
|
|||
# Skip the test: the filesystem encoding is unable to encode the filename
|
||||
supports_unicode = False
|
||||
|
||||
if supports_unicode and not support.has_no_debug_ranges():
|
||||
if supports_unicode:
|
||||
def test_unicode(): """
|
||||
Check doctest with a non-ascii filename:
|
||||
|
||||
|
@ -2876,10 +2876,8 @@ Check doctest with a non-ascii filename:
|
|||
Traceback (most recent call last):
|
||||
File ...
|
||||
exec(compile(example.source, filename, "single",
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
File "<doctest foo-bär@baz[0]>", line 1, in <module>
|
||||
raise Exception('clé')
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
Exception: clé
|
||||
TestResults(failed=1, attempted=1)
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue