[ExceptionGroup] Inconsistent raise inside except*

andriilahuta · GitHub

Bug report

When raising inside except* block and the caught exception wasn't an ExceptionGroup originally, then raised exception doesn't get wrapped in ExceptionGroup:

try: try: raiseTypeError(1) # prints ValueError(3)raiseExceptionGroup('', [TypeError(2)]) # prints ExceptionGroup('', [ValueError(3)]) except* TypeError: raiseValueError(3) exceptBaseExceptionase: print(repr(e))Your environment

CPython versions tested on: 3.11.3

Operating system and architecture: Windows 11 / Ubuntu 22.04

Linked PRs

gh-103590: do not wrap a single exception raised from a try-except* #103665

[3.11] gh-103590: do not wrap a single exception raised from a try-except* #104094

gh-103590: mention that the change is included in 3.11.4 and clarify except* documentation #104095