Skip to content

raise_single_exception_from_group causes SystemExit to have no exit status #3275

Closed
@seowalex

Description

@seowalex

raise_single_exception_from_group was introduced as part of #3240 and #3197, but handles KeyboardInterrupt and SystemExit by wrapping the original exception in an exception of the same type:

# immediately bail out if there's any KI or SystemExit
for e in eg.exceptions:
    if isinstance(e, (KeyboardInterrupt, SystemExit)):
        raise type(e) from eg

Notably, this causes the resulting SystemExit to have no exit status, so system.exit(1) (or really any other exit status) does not properly set the exit status. I do not see a good reason why the exception should not be raised directly:

# immediately bail out if there's any KI or SystemExit
for e in eg.exceptions:
    if isinstance(e, (KeyboardInterrupt, SystemExit)):
        raise e from eg

Was there a reason for this handling?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions