-
-
Notifications
You must be signed in to change notification settings - Fork 369
Open
Description
This snippet eats cause&context
Lines 1387 to 1389 in 9c909fa
except BaseExceptionGroup as exc: | |
if len(exc.exceptions) == 1: | |
raise exc.exceptions[0] from None |
a la https://flake8-async.readthedocs.io/en/latest/rules.html#async123
we currently only run the ruff reimplementation of flake8-async, which hasn't added that rule. So we should maybe consider running flake8-async as well, disabling any rules that ruff handles [better], or are noisy.
It should make use of trio._util.raise_saving_context
.
repro:
import trio
async def task(task_status: trio.TaskStatus) -> None:
e = ValueError("foo")
e.__cause__ = SyntaxError("bar")
e.__context__ = TypeError("baz")
raise e
async def main() -> None:
async with trio.open_nursery() as nursery:
await nursery.start(task)
try:
trio.run(main)
except ExceptionGroup as excgroup:
# should be SyntaxError, is None
print(excgroup.exceptions[0].__cause__)
# should be TypeError, is the exceptiongroup
print(repr(excgroup.exceptions[0].__context__))
Metadata
Metadata
Assignees
Labels
No labels