-
Notifications
You must be signed in to change notification settings - Fork 68
Debugger doesn't stop on uncaught exceptions in third party libraries #2027
Comments
Try adding |
This scenario should not be affected by that setting - it should report the exception the moment it crosses into user code. It looks like async is what's causing the problem here. |
The same thing happens with purely sync code. Bad library:
Build the library and install the wheel into another project, like I described in the first post. Run a simple test function:
The debugger ignores the exception and the error is output into the terminal. @karthiknadig thanks for the suggestion, but that is not what I am looking for. Using Essentially, what I expect can be illustrated with this example: You wouldn't expect it to suddenly jump into standard library code in this case? It should stop at the |
@andersea Ah!. We addressed a bunch of async issues in the new version of the debugger. Can you try using the insiders version of the python extension (from here)? Add this to your user
The above steps should enable the new debugger. If everything works well, then when you start debugging in the command line it should have |
Sorry, still doesn't work. As I mentioned, I don't think this is async related actually. Console output:
This is using my second example library with only sync code, from my previous comment. |
If I enable the option Raised exceptions - then the example behaves pretty much as I expect, however this will come with the drawback of halting on any exception, no matter if I handle it or not. A lot of code in python uses exceptions as part of normal branching: https://devblogs.microsoft.com/python/idiomatic-python-eafp-versus-lbyl/ So I open myself up to being flooded with exceptions that are expected and already handled, like in this screenshot: The uncaught exceptions option exists for exactly this purpose. (Note that, although in the screenshot I write in the comment that I expect the debugger to stop, in the actual screenshot'ed code, it should not stop, since in this case I catch the error. It only stops because I am using the Raised exceptions option.) |
@fabioz Can you look at this one? |
Sure... I was actually taking a look at uncaught exceptions in third party libraries as a part #1946 (see my comment: #1946 (comment))... I'll double check to see if this use case is also fixed when I finish #1946. |
…icrosoft#2027 This commit also makes sure that unhandled exceptions raised in libraries are shown if some frame from its stack is in user code (when justMyCode:true).
…icrosoft#2027 This commit also makes sure that unhandled exceptions raised in libraries are shown if some frame from its stack is in user code (when justMyCode:true).
@fabioz @karthiknadig is this fix included in current vscode-python? Because it still doesn't work. |
@andersea It should be included in ptvsd 5.0.0a12. You can check the version that you have with: import ptvsd
print(ptvsd.__version__) |
@int19h Thanks, I had version 4, so I deleted that, made sure the above optin section was in my settings.json and now it says 5.0.0a12. The test case appears to work now. Thanks. Edit: I am using the insiders build of the extension, also. |
Environment data
"python.jediEnabled"
set to; more info How to update the language server to the latest stable version vscode-python#3977): false (language server)Additional settings:
In the debugger tab:
I have 'Raised Exceptions' unchecked.
I have 'Uncaught Exceptions' checked.
(As a side note, I think it is very unclear how these settings are supposed to interact. I can't see anything in any documentation anywhere.)
launch.json:
Expected behaviour
If an exception is raised in a third party library. Code should stop on the line of code that called into the third party library.
Actual behaviour
The exception is ignored by the debugger, causing the program to exit with an error and the exception to be printed to the terminal.
Steps to reproduce:
(0. I tested both sync and async versions. I use trio as async library, so this needs to be added to the venv.)
__init__.py
file I added the following code.__init__.py
I build the library using poetry build. This creates a wheel file in the dist subdir.
I create another test project using poetry new.
In the test project I add the wheel file using
poetry add ..\test_library\dist\<name of wheel file>
In the test project I add the following test code:
Logs
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)Output from
Console
under theDeveloper Tools
panel (toggle Developer Tools on underHelp
; turn on source maps to make any tracebacks be useful by runningEnable source map support for extension debugging
)The text was updated successfully, but these errors were encountered: