-
Notifications
You must be signed in to change notification settings - Fork 142
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
Breakpoints don't work in notebooks #844
Comments
If you run the same steps with a Python 3.9 environment, the stop event fires. |
I'll investigate. |
Let me know if you need more information on setting it up. I was kinda brief on how to create the environment. |
@rchiodo I did the investigation. This is quite an elusive issue ;) Apparently They probably do a lot of magic under the hood, so, the frame that's received by the debugger tracing does have the proper The best fix for this needs to be done in Another fix could be done in the debugger (under a flag) to not do that optimization and always trace all frames from a file if there's any breakpoint in that file -- this means that the debugger will need to trace much more (and would thus be slower), which isn't ideal, but it's something to keep in mind if this can't/won't be fixed by A workaround users can use is always doing things within a method and then call it at the end or using try..except. In these cases the execution isn't done line-by line and the debugger works. |
Note: the related code seems to be: https://github.com/ipython/ipython/blob/0f4a73c91db71cde174275337fc5e226acc9dd7d/IPython/core/interactiveshell.py#L3144 |
Actually, seeing their code it seems that it works the same in both versions of Python, so, I researched a bit more and the difference is not the frame manipulation per-se. The issue is that the debugger caches the decision on whether to trace something or not based on a cache key which is: |
@fabioz did you find out anything else? Do you think this is a problem in ipykernel or is it something that Python 3.10 is causing? |
@rchiodo, I haven't finished investigating, so, I'm still not sure who is the culprit for that odd |
After investigating a bit more this really seems to be caused by Python 3.10. I sent a message to python-dev as this seems like a regression for me (but maybe it isn't and it was done on purpose?). https://mail.python.org/archives/list/[email protected]/thread/VXW3TVHVYOMXDQIQBJNZ4BTLXFT4EPQZ/ I still don't have a good workaround for having multiple functions all with the same co_firstlineno in the same file... |
Thanks for the follow up. |
Humm, I think that it may be possible to create a new code object based on that code object but with a new |
I provided a fix to ipython itself (ipython/ipython#13535). |
… caching frame info. Fixes microsoft#837 Fixes microsoft#844
… caching frame info. Fixes microsoft#837 Fixes microsoft#844
… caching frame info. Fixes microsoft#837 Fixes microsoft#844
I ended up doing a fix in the debugger itself for this given that another library (hypothesis) got into the same situation (see comments in the related PR: #851). |
Environment data
Actual behavior
See this issue: microsoft/vscode-jupyter#8803 (and this issue: ipython/ipykernel#841)
Debugging a cell in a notebook requires you set a breakpoint on the first line. But only with Python 3.10. With Python 3.9 it doesn't require a breakpoint on the first line.
Steps to reproduce:
The breakpoint should hit.
Looking at the logs, it looks like the breakpoints are sent and verified:
But for some reason the stop event never occurs.
Notebook to repro:
debug_failure.zip
Logs of failure:
failurelogs.zip
Logs of success if I stick a breakpoint on the first line of the cell:
successlogs.zip
The text was updated successfully, but these errors were encountered: