[✓] I checked the documentation and found no answer [✓] I checked to make sure that this issue has not already been filed [✓] I'm reporting the issue to the correct repository
Description
The stack traceback of some errors is displayed incorrectly. Below are two examples of an incorrect stacktrace and correct stacktrace. The incorrect one creates a pandas dataframe in a faulty manner, raising an exception, its stacktrace points to a command in the finally block instead of the pandas dataframe creation which is the actual issue.
The correct example shows how a non-existing key of a dictionary is called, its stacktrace does not point to a statement in the finally block but rather points to the line that actually causes the issue.
Some things i've tried or noticed:
* the correct example contains hyperlinks to each code-line, while the incorrect one doesn't, maybe this is a hint to the cause. I therefore included the stacktrace of both examples in raw text as well as html.
* running the'incorrect stacktrace' example in pure python (.py file) results in a **correct** stacktrace
* this issue occurs when hosting jupyter notebooks locally, but also in VSCode notebooks using the ipykernel
* Thinking that C-code extensions of Python could be a potential source, I also tried raising errors using torch (torch.tensor('invalid_type') but this results in a correct stacktrace.
* aside of torch i also tried incorrectly initiating classes with other packages, this also lead to a correct stacktrace
Originally opened by @dvorst in https://github.com/jupyter/notebook/issues/7242
[✓] I checked the documentation and found no answer [✓] I checked to make sure that this issue has not already been filed [✓] I'm reporting the issue to the correct repository
Description
The stack traceback of some errors is displayed incorrectly. Below are two examples of an incorrect stacktrace and correct stacktrace. The incorrect one creates a pandas dataframe in a faulty manner, raising an exception, its stacktrace points to a command in the finally block instead of the pandas dataframe creation which is the actual issue.
The correct example shows how a non-existing key of a dictionary is called, its stacktrace does not point to a statement in the finally block but rather points to the line that actually causes the issue.
Some things i've tried or noticed:
incorrect stacktrace
code
stacktrace text
stacktrace html
correct stacktrace
code
stacktrace text
stacktrace html
Context
This occurs in the browser with notebook 7.0.7, but also in VSCode notebooks with ipykernel 6.29.2
IPython : 8.21.0 ipykernel : 6.29.2 ipywidgets : not installed jupyter_client : 8.6.0 jupyter_core : 5.7.1 jupyter_server : 2.12.5 jupyterlab : 4.1.0 nbclient : 0.9.0 nbconvert : 7.16.0 nbformat : 5.9.2 notebook : 7.0.7 qtconsole : not installed traitlets : 5.14.1
pandas : 2.2.0 vscode. : 1.86.0 Troubleshoot Output
I did not include the command line output as this caused the maximum amount of characters allowed to be exceeded.