code: use current excinfo when formatting chained BaseExceptionGroup by bysiber · Pull Request #14221 · pytest-dev/pytest

@bysiber

In repr_excinfo, the BaseExceptionGroup branch incorrectly uses
the original excinfo instead of excinfo_ (which tracks the current
exception in the chain). This means that when walking __cause__ or
__context__ chains, filter_excinfo_traceback and format_exception
always operate on the first exception rather than the current one.

The non-group branch on the else side already uses excinfo_
correctly.

@bysiber

Test that when a BaseExceptionGroup appears as a chained exception,
the traceback output correctly shows both the ExceptionGroup and the
outer exception, using the current excinfo_ rather than the original.

nicoddemus