You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test_except_star does not cover except* handlers raising a non-Exception BaseException #160659
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.
Activity
gh-160659: Add tests for `except*` handlers that raise a `BaseExcepti…