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

sys.exit(0) does not break by default, but sys.exit() does #489

Closed
nedsociety opened this issue Dec 6, 2020 · 5 comments
Closed

sys.exit(0) does not break by default, but sys.exit() does #489

nedsociety opened this issue Dec 6, 2020 · 5 comments

Comments

@nedsociety
Copy link

nedsociety commented Dec 6, 2020

Environment data

  • debugpy version: 1.2.0
  • OS and version: Win10 18363.1198
  • Python version (& distribution if applicable, e.g. Anaconda): 3.9.0
  • Using VS Code or Visual Studio: vscode 1.51.1, Python extension v2020.11.371526539

Description

This code triggers breakpoint even if the "Raised Exceptions" option is turned off:

import sys
sys.exit()

image

This seems inconsistent. If I specify the exit code like sys.exit(0) explicitly then it ignores SystemExit as expected.

@karthiknadig
Copy link
Member

In the launch JSON, add this and see if it helps:

"breakOnSystemExitZero": true

@nedsociety
Copy link
Author

nedsociety commented Dec 8, 2020

"breakOnSystemExitZero": true

Well it makes sys.exit(0) also breaks as well, which is even more undesirable. The expected behavior in default should be:

  • sys.exit() doesn't break (but currently breaks)
  • sys.exit(0) doesn't break
  • sys.exit(n) for nonzero n breaks

@karthiknadig
Copy link
Member

Ah! I see. Sorry, I misunderstood the issue.

@fabioz
Copy link
Collaborator

fabioz commented Dec 10, 2020

It seems that the issue is that SystemExit.code is None in this case (and not 0).

fabioz added a commit to fabioz/debugpy that referenced this issue Dec 10, 2020
fabioz added a commit to fabioz/debugpy that referenced this issue Dec 12, 2020
@fabioz fabioz closed this as completed in a7282e9 Dec 12, 2020
@danielniccoli
Copy link

@fabioz @karthiknadig @nedsociety

The behavior of debugpy is not in compliance with the specifications. Because the underlying issue is broader, I raised a separate ticket on the matter, which explains the problem and suggests a solution that should not only fix the issue you are having, but other issues as well. Unforatunately, it was closed and moved to a discussion. Please contribute, if you wish to see it fixed.

The issue: #1590
The discussion: #1591

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants