-
Notifications
You must be signed in to change notification settings - Fork 158
Debugger does not recognize that exception is handled in single line except statement scenario #404
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
Comments
/cc @fabioz |
I'll start to take a look at this. |
Note: from the logs it's possible to see that the filter is also for
So, the correct thing is not to break in the user unhandled mode as it's a handled exception. |
I'm still working on this... @int19h as this is an issue on user handled exceptions, maybe we should only enable those on a default build when this is fixed |
Unfortunately I still haven't been able to fix it... let me try to give some feedback on why this happens and why this is tricky: During Python tracing, Python does not provide a way to know whether we're exiting because of an exception or because of a return (it provides a tracing for the exception and another for the return), so, to differentiate we analyze the bytecode and obtain the information on where the With that the debugger uses some heuristics based on where the I still haven't discovered a really good way to differentiate here -- what I thought for now is checking the So, I'm still investigating... I'll spend at most one more day checking if I can come up with a better approach, if I can't I'll probably do the pragmatic thing and just additionally check if the return value is really |
Environment data
import debugpy; print(debugpy.__version__)
if uncertain)Actual behavior
Debugger breaks on exception when it shouldn't given the exception is handled. Break on thrown is 'off'.
Expected behavior
Debugger does not break on exception
Steps to reproduce:
beautifulsoup4
andlxml
in Python 3.7result: breaks on exception thrown

change the implementation to have the return statement on its own line like this:
result: does not break, it correctly recognizes that it is handled
exception settings:

logs for both scenarios:
one-liner-breaks.txt
two-liner-no-break.txt
from developer community feedback at https://developercommunity.visualstudio.com/content/problem/1158181/python-exception-in-try-block-stops-in-debugger.html?childToView=1173634
The text was updated successfully, but these errors were encountered: