Skip to content

test_except_star does not cover except* handlers raising a non-Exception BaseException #160659

Closed

Description

@agronholm

Lib/test/test_except_star.py has no test where an except* handler raises a BaseException that isn't an Exception (for example KeyboardInterrupt, SystemExit, or a custom BaseException subclass). Every handler in TestExceptStarRaise and TestExceptStarRaiseFrom raises an Exception subclass (TypeError or SyntaxError), and no other except* handler in Lib/test raises a BaseException-only type, directly or indirectly.

CPython already behaves correctly here: the raised exception propagates on its own, or is combined with any other raised exceptions and the unmatched remainder into a BaseExceptionGroup. But because nothing tests this, other implementations that run CPython's test suite aren't told when they get it wrong. PyPy passes all of test_except_star.py, yet raises an internal AssertionError in exactly this case, and also builds an ExceptionGroup where a BaseExceptionGroup is needed. See pypy/pypy#5689. The bug was found through a test in the exceptiongroup backport (agronholm/exceptiongroup#163), not through CPython's tests.

I'll send a test-only PR that adds tests for this case to TestExceptStarRaise.

Linked PRs

Activity

  1. added a commit that references this issue on Oct 26, 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

    testsTests in the Lib/test dir

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions