Skip to content

debugger runs code _after_ stopping on unhandled exception #1956

@Spongman

Description

@Spongman

Before creating a new issue, please check the FAQ to see if your question is answered there.

Environment data

  • debugpy version: 2025.10.0
  • OS and version: windows 10.0.19045.6218
  • Python version Python 3.9.21
  • Using VS Code or Visual Studio: vscode 1.103.2

Actual behavior

debug this

class TestInstance:
    def __init__(self):
        print('__init__')
        pass

    def __enter__(self):
        print('__enter__')
        return self

    def __exit__(self, excType, exc, tb):
        print('__exit__')
        pass

def test():
    with TestInstance() as ti:
        print('yield')
        yield ti

for ti in test():
    print('raise')
    raise Exception

it prints

__init__
__enter__
yield
raise
__exit__

and stops at the raise line (because it's an unhandled exception)

it shouldn't print this __exit__. it should stop on the raise.

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