-
Notifications
You must be signed in to change notification settings - Fork 675
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
Visual Studio 2022 keeps breaking on exception which seems to be handled in Python internally #7442
Comments
Hi @int19h, do you know if there's a way to not break on this exception in VS? |
The fundamental problem here is that it is not known at the point where exception is thrown in Python whether it will be handled or not, because the exception system is one-pass rather than two-pass (as in e.g. C++ or C#). The debugger approximates it by looking at the call stack and inspecting bytecode to see which try-except blocks are currently active. But exceptions can also be handled in native code, and that's what CPython itself does in this case. Thus, as things stand, the only workaround is to disable reporting that particular exception class entirely - in VS, you can do it via Debug -> Windows -> Exception Settings. Now, it might be possible to improve the heuristics by looking at more than just try..except blocks - e.g. in this case, the debugger could assume that it's okay for a |
@int19h I already tried disabling all exceptions in the Debug -> Windows -> Exception Settings, but this exception still breaks the debug session. So at the moment we don't have any functional workaround for this (apart from hitting run many times each session). |
This issue was closed because it has been stalled for 30 days with no activity. If the issue still persists, please reopen with the information requested. Thanks. |
This issue is still present in late 2024 with VS 2022 Version 17.11.2. It's very disruptive to the debugging experience. |
This issue has been moved from a ticket on Developer Community.
[severity:It's more difficult to complete my work]
I want to debug my Python application with Visual Studio 2022 Pro - we're just evaluating it for our purpose - and am just configuring the solution. I've stumbled upon a very persistant exception, which breaks execution every time I debug my application and it is annoying that I have to continue several times before the application actually runs.
The minimum sample to preproduce the issue looks like this:
What happens is that return
super().__getattribute__(item)
throwsAttributeError
exception several times. This seems all to be part of some internal Python logic. I got to the point just before the exception and it looks like this exception is triggered inenum.py
, specifically__new__
function, which callshasattr(enum_member, '_value_')
.I couldn't go deeper with the debugger, as it seems this part is not implemented in Python. But considering how the code executes normally afterwards, as if the exception wasn't thrown at all, I'm guessing there is some internal code, which handles this exception.
The main problem seems to be that Visual Studio seems to think this is an unhandled exception and breaks there unconditionally. I tried disabling all exceptions, so it wouldn't break on any, but what I see is that it breaks only on unhandled exceptions. So I'm guessing this is the gist of the problem. I also tried toggling the option Enable Just My Code, but it made no difference in this case.
If I execute this code without a debugger it finishes without any unhandled exceptions.
Other debuggers, such as PyCharm which we are using at the moment, by default do not break on this exception.
This is a blocker for our team, as we don't want to deal with these breaks every time we start debugging our application.
Is there a way to prevent this behavior? If not, do you have a plan to fix it?
Original Comments
Feedback Bot on 3/3/2023, 00:06 AM:
(private comment, text removed)
Original Solutions
(no solutions)
The text was updated successfully, but these errors were encountered: