Skip to content

Docs: a single exception raised in an except* clause is not wrapped in a group, but the Reference says it is #162571

Backlog

Description

@Robertboy18

Documentation

The except* section of the Reference (https://docs.python.org/dev/reference/compound_stmts.html#except-star) says: "After all except* clauses execute, the group of unhandled exceptions is merged with any exceptions that were raised or re-raised from within except* clauses. This merged exception group propagates on". But when every exception of the group was handled and a clause raises one new exception, that exception propagates by itself (gh-103590), so an except RuntimeError around the statement catches it:

try:
    try:
        raise ExceptionGroup("eg", [ValueError(1)])
    except* ValueError:
        raise RuntimeError("new")
except BaseException as e:
    print(repr(e))
RuntimeError('new')

The 3.12 docs say this ("If this list contains more than one exception to reraise, they are combined into an exception group", from gh-104095); the sentence was lost in the rewrite of gh-136150. I found it while writing a Lean spec of Python.

Linked PRs

Activity

  1. added
    docs
    on Nov 24, 2026
  2. added a commit that references this issue on Nov 24, 2026
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

    docs

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions