Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[errors-] options.debug_stacktrace_full for more callstack #2586

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

midichef
Copy link
Contributor

@midichef midichef commented Oct 24, 2024

This PR is an aid to debugging. It adds more levels to the usual exception traceback, when an option is set.

Why this is useful: when viewing an exception trace, Python only shows the stack trace to the level of the function that caught the exception. Often such an exception trace will top out with a common wrapper function like wrapply() or callNoExceptions(). And that's too ambiguous to identify the line causing a bug.

Here is some sample output to show the effect. I've split it into two parts. The top part is the new extra output, the bottom is the usual exception trace. The full trace doubles the length of the traceback, as well as having a different format. So it's good to default off for most users.

File "/home/midichef/.venv/bin/vd", line 6, in <module>
    visidata.main.vd_cli()
  File "/home/midichef/.venv/lib/python3.12/site-packages/visidata/main.py", line 382, in vd_cli
    rc = main_vd()
  File "/home/midichef/.venv/lib/python3.12/site-packages/visidata/main.py", line 344, in main_vd
    run(vd.sheets[0])
  File "/home/midichef/.venv/lib/python3.12/site-packages/visidata/vdobj.py", line 34, in _vdfunc
    return getattr(visidata.vd, func.__name__)(*args, **kwargs)
  File "/home/midichef/.venv/lib/python3.12/site-packages/visidata/extensible.py", line 65, in wrappedfunc
    return oldfunc(*args, **kwargs)
  File "/home/midichef/.venv/lib/python3.12/site-packages/visidata/extensible.py", line 65, in wrappedfunc
    return oldfunc(*args, **kwargs)
  File "/home/midichef/.venv/lib/python3.12/site-packages/visidata/extensible.py", line 65, in wrappedfunc
    return oldfunc(*args, **kwargs)
  File "/home/midichef/.venv/lib/python3.12/site-packages/visidata/mainloop.py", line 322, in run
    ret = vd.mainloop(scr)
  File "/home/midichef/.venv/lib/python3.12/site-packages/visidata/extensible.py", line 65, in wrappedfunc
    return oldfunc(*args, **kwargs)
  File "/home/midichef/.venv/lib/python3.12/site-packages/visidata/mainloop.py", line 252, in mainloop
    vd.callNoExceptions(sheet.checkCursor)
Traceback (most recent call last):
  File "/home/midichef/.venv/lib/python3.12/site-packages/visidata/mainloop.py", line 28, in callNoExceptions
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/midichef/.venv/lib/python3.12/site-packages/visidata/extensible.py", line 79, in wrappedfunc
    r = oldfunc(*args, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/midichef/.venv/lib/python3.12/site-packages/visidata/sheets.py", line 643, in checkCursor
    elif self.bottomRowIndex < self.cursorRowIndex:
         ^^^^^^^^^^^^^^^^^^^
  File "/home/midichef/.venv/lib/python3.12/site-packages/visidata/sheets.py", line 370, in bottomRowIndex
    return self.topRowIndex+self.nScreenRows-1
                            ^^^^^^^^^^^^^^^^
  File "/home/midichef/.venv/lib/python3.12/site-packages/visidata/sheets.py", line 414, in nScreenRows
    n = (self.windowHeight-self.nHeaderRows-self.nFooterRows)
                                            ^^^^^^^^^^^^^^^^
  File "/home/midichef/.venv/lib/python3.12/site-packages/visidata/sheets.py", line 427, in nFooterRows
    return len(self.allAggregators) + 1
               ^^^^^^^^^^^^^^^^^^^
  File "/home/midichef/.venv/lib/python3.12/site-packages/visidata/extensible.py", line 149, in call_if_not
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/midichef/.venv/lib/python3.12/site-packages/visidata/sheets.py", line 780, in allAggregators
    col = self.availCols[vcolidx]
          ~~~~~~~~~~~~~~^^^^^^^^^
IndexError: list index out of range

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant