Commit 51e3166
Fix exceptions raised before task_status.started() losing cause and context
When a task raised an exception before calling task_status.started(),
Nursery.start() unwrapped it from the internal ExceptionGroup using
`raise exc.exceptions[0] from None`, which explicitly set __cause__
to None and __suppress_context__ to True — destroying any cause or
context the original exception carried.
Use raise_saving_context() instead, which preserves both __cause__
and __context__ on the re-raised exception, consistent with how
raise_single_exception_from_group() handles the same pattern.
Fixes #3261.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 6deaf2a commit 51e3166
2 files changed
+22
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
1466 | 1466 | | |
1467 | 1467 | | |
1468 | 1468 | | |
1469 | | - | |
| 1469 | + | |
1470 | 1470 | | |
1471 | 1471 | | |
1472 | 1472 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2920 | 2920 | | |
2921 | 2921 | | |
2922 | 2922 | | |
| 2923 | + | |
| 2924 | + | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
| 2928 | + | |
| 2929 | + | |
| 2930 | + | |
| 2931 | + | |
| 2932 | + | |
| 2933 | + | |
| 2934 | + | |
| 2935 | + | |
| 2936 | + | |
| 2937 | + | |
| 2938 | + | |
| 2939 | + | |
| 2940 | + | |
| 2941 | + | |
| 2942 | + | |
2923 | 2943 | | |
2924 | 2944 | | |
2925 | 2945 | | |
| |||
0 commit comments