Uh oh!
There was an error while loading. Please reload this page.
gh-93883: elide traceback indicators when possible - #93994
Conversation
9e77485 to
f8b316fComparearhadthedev
commented
Jun 19, 2022
For backlinking purposes the parent issue is gh-93883 (until the link autoiinsertion is returned back; cannot find that PR). |
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
```
WORK IN PROGRESS
TODO:
* C traceback implementation
* update documentation472339e to
c06257bCompareRather 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).
terryjreedy
commented
Jun 24, 2022
I approve of the idea of the change and, of course, adjusting the IDLE test. I would like to see this backported as I consider the noise a visual bug in the new feature. |
Uh oh!
There was an error while loading. Please reload this page.
| def test_basic_caret(self): | ||
| def f(): | ||
| raise ValueError("basic caret tests") | ||
| if True: raise ValueError("basic caret tests") |
There was a problem hiding this comment.
Haha, this is a bit confusing the first time I just saw it. I understand that this is so the raise doesn't get elided because is fully covered, but maybe we can do the same with a ternary operation raise ValueError("blech") or ValueError("never executed"). I don't have a string opinion to be honest, just that is a bit confusing :)
There was a problem hiding this comment.
Rightly noted. I had a pending commit to explain that idiom. Let's see how it looks after adding that.
Uh oh!
There was an error while loading. Please reload this page.
| f' + Exception Group Traceback (most recent call last):\n' | ||
| f' | File "{__file__}", line {self.callable_line}, in get_exception\n' | ||
| f' | exception_or_callable()\n' | ||
| f' | ^^^^^^^^^^^^^^^^^^^^^^^\n' |
There was a problem hiding this comment.
I am a bit concerned that we are missing some test coverage with exception groups + debug ranges here. We should make sure we have at least one specific exception group test that covers debug ranges as well.
There was a problem hiding this comment.
Yes-- that was my intention with the added test_caret_exception_group() test. I thought it would be better to leave the onus on the CaretTests suite.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
miss-islington
commented
Jul 11, 2022
Thanks @belm0 for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
) * pythongh-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). (cherry picked from commit da71751) Co-authored-by: John Belmonte <john@neggie.net>
bedevere-bot
commented
Jul 11, 2022
GH-94734 is a backport of this pull request to the 3.11 branch. |
kumaraditya303
commented
Jul 11, 2022
This change broke all main branch CI and buildbots. See https://github.com/python/cpython/runs/7277260781?check_suite_focus=true |
belm0
commented
Jul 11, 2022
Sorry-- I hadn't rebased in a few weeks, perhaps automatic merge let some new test code through that needs revision. Looking... |
PR python#93994 was merged without being rebased in a few weeks, and some new test code using the old scheme passed through automatic merge.
belm0
commented
Jul 11, 2022
Fix is at #94737 hopefully. I'll be AFK for about 2 hours. |
…onGH-93994) * pythongh-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 ``` (cherry picked from commit da71751) Co-authored-by: John Belmonte <john@neggie.net>
…#94737) PR python#93994 was merged without being rebased in a few weeks, and some new test code using the old scheme passed through automatic merge. (cherry picked from commit 1fdc35e)
…onGH-93994) * pythongh-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).. (cherry picked from commit da71751) Co-authored-by: John Belmonte <john@neggie.net>
…H-94740) Elide traceback column indicators when the entire line of the frame is implicated. This reduces traceback length and draws 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 ``` Automerge-Triggered-By: GH:pablogsal
Elide traceback column indicators when the entire line of the
frame is implicated. This reduces traceback length and draws
more attention to the remaining (very relevant) indicators.
Example:
TODO:
See also the original feature issue: gh-88116.