Skip to content

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

Closed

Description

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.

Activity

  1. karthiknadig commented on Dec 8, 2020

    @karthiknadig
    Member

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

    "breakOnSystemExitZero": true
    
  2. nedsociety commented on Dec 8, 2020

    @nedsociety
    Author

    "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
  3. karthiknadig commented on Dec 8, 2020

    @karthiknadig
    Member

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

  4. fabioz commented on Dec 10, 2020

    @fabioz
    Collaborator

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

  5. added 2 commits that reference this issue on Dec 10, 2020
    58aa130
    0aa33c5
  6. danielniccoli commented on May 31, 2024

    @danielniccoli

    Fabio Zadrozny (@fabioz) Karthik Nadig (@karthiknadig) Myungbae Son (@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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions