Skip to content
New issue

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

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

Already on GitHub? # to your account

stacktrace: fix missing caller frames and remove carets from vd_cli() traces #2651

Merged
merged 3 commits into from
Jan 14, 2025

Conversation

midichef
Copy link
Contributor

4df7308 fixes a bug in #2586. The caller of stacktrace() was being removed in too many cases, like in getCell(). Now the only caller of stacktrace that is removed is exceptionCaught().

Test case: vd = 1+[] z^E and note how there is no line that ends with in getCell until after applying 4df7308.

aa4285b cleans up the carets in tracebacks from vd_cli (seen in Python 3.11 and up). Like in the traceback when an HTTP connection closes:

  File "/usr/lib/python3.12/http/client.py", line 331, in begin
    version, status, reason = self._read_status()
                              ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/http/client.py", line 300, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

You can test this with netcat: nc -l -p 2000 -w 1& vd http://localhost:2000/

I tested aa4285b in the most recent Python major versions from 3.8-3.12.

Note that the new exception formatting will not happen for events like KeyboardInterrupt. So the carets will be seen if you do vd /dev/zero then hit ^C.

Callers like getCell() were being wrongly excluded.

Also fixes IndexError when trimming short call stacks, three levels deep.
Copy link
Owner

@saulpw saulpw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Man, why is it so complicated! We just need a decent stacktrace. (Not blaming you, I'm mad at Python on this one.)

@anjakefala
Copy link
Collaborator

Thank you always including test cases for your PRs!

@anjakefala anjakefala merged commit 94d1b6f into saulpw:develop Jan 14, 2025
14 checks passed
@midichef midichef deleted the stacktrace_fix_and_extend branch January 21, 2025 01:06
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants