-
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
User Uncaught Exceptions setting should be false by default #751
Comments
We are seeing similar issues with ImportErrors stopping our flask server from starting only when run through VSC. This same code is running in our development environment with no errors and in docker containers locally. If you hit play on each exception (12 to 20 times) you can eventually step through all the exceptions and the server will eventually start. |
There's a new exception setting (which by default is true) which tracks This setting is close to the It's very useful when users want to deal with exceptions from test frameworks (for instance, an exception raised in a test will be shown if it bubbles up in the test framework), but in this particular case, I agree it's really not useful. The solution is unchecking the @karthiknadig @int19h Do you think this should be set to |
These are not Uncaught User Exceptions. These Exceptions only happen when run using VSC. These Exceptions don't occur if run out side of VSC. |
@sknowles0143 they do happen when running outside of VSC, the only difference is that when running inside of VSC they are shown to you due to the I believe you're confusing this with i.e.: |
i.e.: Maybe |
Thanks a lot! Disabling User Uncaught Exceptions solved the issue. Maybe add some warning saying that the exception is because of this new feature. I lost like 5 hours figuring out that it is not actually my code that is not working properly and almost went crazy figuring out what's happening. The worst thing is that isinstance checked internally hasattr for every member in random order, so the error message was always about a random member, and no code trying accessing those members was visible anywhere. Can you clarify why isinstance causes the debugger to stop, but hasattr itself does not? Hasattr is based on the AttributeError exception, and it is also an interface between a library and the user code. |
|
This is also an issue when using @Property decorators. Since the debugger appears to to now call hasattr on an uninstantiated object on file import, this can cause exceptions or other bad behavior. I am seeing an import loop and other problems due to this bad behavior. For instance, any accessor using 'self' is likely to throw an exception now since the 'self' argument in this case is really 'cls'. |
Given the issues that came up so far, I agree that we should disable this by default. Going forward, we can try to come up with some heuristics to avoid hitting this for the more common Python patterns, and then flip it back if those prove to be sufficient in real world usage. |
What constitutes "user code" vs "library code"? We're seeing the debugger stop on exceptions that are fully raised and caught in library code. |
In general anything in site-packages and lib is library code, anything else is user code... So, any exception that at some point passes through user code (even if originally raised in library code) and then keeps on being raised until it reaches library code is considered here. In general, this is nice for test frameworks, which can stop at caught exceptions inside those -- and can under some circumstances -- show actual errors of unexpected exceptions, but it seems it's also common under some frameworks to work this way (so, the default should probably be opt in instead of opt out). A second step as @int19h mentioned would be trying to discover those common scenarios to skip those, but this is probably a much harder task (given that finding which are the common cases where this shouldn't be reported is hard). Given that initially this was done to support showing exceptions that are handled in unit-testing frameworks, maybe we could whitelist for those frameworks instead of blacklisting other scenarios (in which case the breakpoint would be renamed to something as "Exceptions caught by test frameworks"). |
Should this be closed? It was listed as fixed in the 1.5.1 release. |
Environment data
python.languageServer
setting: PylanceExpected behaviour
The following code should not raise an exception.
Actual behaviour
The code stops on the "raise AttributeError()" line and shows an exception is raised. If one clicks "Continue", the code continues correctly. But it is still pretty annoying to click it every single time it happens in a big project.
If one runs it from the terminal without VSCode debugger, it runs without issues.
Steps to reproduce:
Run the code above from vscode. The launch.json entry for it:
Other
It might be related to microsoft/vscode-python#17687, but not sure.
The text was updated successfully, but these errors were encountered: