Skip to content
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

Debugger breaks on Handled exceptions or only on class Instantiation #6311

Closed
oseredia opened this issue Nov 19, 2020 · 2 comments
Closed

Debugger breaks on Handled exceptions or only on class Instantiation #6311

oseredia opened this issue Nov 19, 2020 · 2 comments

Comments

@oseredia
Copy link

Describe the bug
Debugger either breaks on class instantiation instead of in class code or breaks on all raised exceptions while breaking properly in class code. When the debugger breaks on class instantiation only there is no indication of which line actually caused the exception. In a large class this makes debugging in Visual Studio a tedious process of manually stepping through code or pressing continue for each handled exception.

Steps to Reproduce

  1. Disable all Python Exceptions in Exceptions Settings (there is no unhandled exceptions to select in the list).
  2. Run with Debugging. Debugger Breaks on class instantiation with no indication of where the error occurred (line 11)
    image

Exception Details:
Message=name 'j' is not defined
Source=...\Scratch.py
StackTrace:
File "...\Scratch.py", line 14, in
H=h()

3.Enable Python Exceptions (there is no Handled Exceptions option to deselect in the list). Run with Debugging: Breaks on Handled Exception (not wanted behaviour)
image
4. Continue to next exception. Breaks where the exception actually occurred (wanted behaviour) in the class and then on instantiation after continuing again.
image
After Continue
image

Expected behavior
The ability to skip handled exceptions and break in class code not only on instantiation. VSCode for example, by selecting break on uncaught Exceptions only the debugger breaks in the class code and skips the handled exception. In a large class this makes debugging in Visual Studio a tedious process which is why I use the VScode debugger to find bugs in large classes
image

Sample Code

#Handled exception
try:
raise ValueError
except:
pass

class H(object):
def init(self):
#unhandled exception
print(j)

if name == "main":
h=H()

This also occurs if the exception is not in init:
image
Behaviour is not seen when not using classes.
image

Configuration information (If you are providing a diagnostics file (see below), skip this section)
VS Version: 16.8.0
PTVS version: 16.8.20241.2
Python version:
Debugger Type (if applicable): New debugger, have not tried on Legacy yet

Diagnostics file
Diagnostic Info 2020-11-19T111217.txt

@huguesv
Copy link
Contributor

huguesv commented Nov 20, 2020

This looks like microsoft/debugpy#399 which has already been fixed in debugpy 1.0.0.
https://github.com/microsoft/debugpy/releases

Can you please do this in both VS and VS Code:

import debugpy
print(debugpy.__version__)

and run under the debugger to see which versions you have in both.

VS 16.8 I believe has 1.0.0rc2 but VS 16.9 Preview 1 (available now) should have 1.0.0.

@AdamYoblick
Copy link
Member

I'm not able to repro this with the latest VS preview and Python 3.7:

image

image

@greazer greazer closed this as completed Jul 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants