Skip to content

3.11 backtrace visual indicators are too verbose #93883

Description

@belm0

I understand that the new visual indicators can be disabled, but we shouldn't have to choose between guaranteed 50% longer backtraces and pertinent column information.

Often, the visual indicator spans the entire line for a large percentage of the backtrace. (I've seen cases in our app where it's true for 100% of the backtrace.)

Proposal: elide the indicators when they span the whole line

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.

before:

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

after:

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

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    on Jun 16, 2022
  2. belm0 commented on Jun 19, 2022

    @belm0
    ContributorAuthor

    I've prototyped the change for traceback.py. Making the equivalent change to C traceback code and updating documentation is still required. I'd like to hear if this change has some support from Python devs before putting more time into the PR.

  3. Zac-HD commented on Jun 23, 2022

    @Zac-HD
    Contributor

    I am very, very keen on this change! Thanks very much @belm0 for thinking of this and implementing a patch 😍

  4. added a commit that references this issue on Jun 24, 2022
  5. belm0 commented on Jun 24, 2022

    @belm0
    ContributorAuthor

    PR #93994 is ready for review

  6. added a commit that references this issue on Jul 11, 2022
  7. added a commit that references this issue on Jul 11, 2022
  8. added a commit that references this issue on Jul 11, 2022
  9. added 3 commits that reference this issue on Jul 11, 2022
  10. added a commit that references this issue on Jul 11, 2022
  11. belm0 commented on Jul 11, 2022

    @belm0
    ContributorAuthor

    The refinement is merged and backported to 3.11 for the beta4 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions