Open damien135 opened 2 years ago
It's been a month and there is no response yet on my report above. Should I provide more information? Am I supposed to add labels to this report? (If so, how?) Please let me know if this is not the right place for this bug report.
So sorry for not getting back to you, @damien135 ! It looks like GitHub Actions messed up and didn't run to add our triage-needed
label, so this fell through the cracks. I am moving this over to debugpy now to see if they know what's going on.
Actually, I was checking it here and it should hit as a User uncaught exception
(the definition of that is whenever there's an exception from user code which would be raised into the standard library the exception should be shown).
In this case the some_context_manager
(user code) would be raised into contextlib
(standard library), which is correct.
i.e.:
So, this isn't really a bug (as it's doing what's intended).
Still, I can see how it can be argued that User uncaught exception
should only be handled if the exception when it goes into the standard library code and it'd not cross back to user code anymore.
So, maybe this could be turned into a feature request for that behavior, still, the question is whether we should have yet another breakpoint type for that or if this should be a flag or whether the current behavior is never valid and only that one should be used...
-- Another possibility would be just making an exception for contexlib
...
Hello Fabioz, thanks for looking into this and for the technical explanation. I'd just like to point out that this was highly confusing to me during debugging. I expected this exception to be caught by the try/except block and therefore be 'silenced'. So I was facing an exception where I didn't want the debugger to break (I just wanted it to be handled by the try/except block), but I wasn't able to "silence" it by any means except by disabling breaks on every other "uncaught" exception as well in the debugger (which I didn't want to do).
Since Python encourages the use of exceptions (EAFP principle), I feel like the pattern I described here isn't too weird to use. I'd argue that what makes most sense here is that the debugger doesn't break. Otherwise, how do I keep working on other parts of this project (where I want to break on uncaught exceptions) without constantly being interrupted by this code snippet (which works as intended and where I just want to trigger particular behavior if an exception is thrown upstream)?
Type: Bug
Behaviour
Expected vs. Actual
Expected behavior: If breakpoints are enabled only for Unchaught Exceptions and User Uncaught Exceptions, the debugger should not break in the code sample below.
Actual behavior: The debugger breaks on line 19.
Steps to reproduce:
class ExampleClass: @some_decorator('some value') def get_property_value(self): return {}
example = ExampleClass() try: test = example.get_property_value() except Exception as ex: print("Exception successfully caught!")
Exception has occurred: Exception (note: full exception trace is shown but execution is paused at: some_context_manager) User uncaught exception! File "...\TestException.py", line 19, in some_context_manager (Current frame) raise Exception("User uncaught exception!") File "...\TestException.py", line 7, in wrapper with self.some_context_manager(parameter): File "...\TestException.py", line 23, in
test = example.get_property_value()
languageServer: "Jedi"