Fix #2607: handle frozen dataclass exceptions - #3522
Closed
sb123sb123 wants to merge 1 commit into
Closed
sb123sb123 wants to merge 1 commit into
sb123sb123 wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3522 +/- ##
===============================================
Coverage 100.00000% 100.00000%
===============================================
Files 128 128
Lines 19471 19483 +12
Branches 1323 1323
===============================================
+ Hits 19471 19483 +12
🚀 New features to boost your workflow:
|
Contributor
|
Thanks, but I don't want to fix this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2607
When
strict_exception_groups=Falsecollapses a single exception group, Trio updates traceback and context metadata on the contained exception. Frozen dataclass exceptions reject normal attribute assignment, so the original exception is replaced byFrozenInstanceError.This change uses
object.__setattr__for Trio internal traceback/context restoration paths and adds a regression test through a real nursery.Testing:
PYTHONPATH=src .venv/Scripts/python.exe -m pytest src/trio/_core/_tests/test_run.py -q- 155 passed, 1 skippedPYTHONPATH=src .venv/Scripts/python.exe -m pytest src/trio/_tests/test_util.py -q- 8 passed.venv/Scripts/ruff.exe check src/trio/_core/_run.py src/trio/_core/_tests/test_run.py src/trio/_util.py- passedpython -m black --check src/trio/_core/_run.py src/trio/_core/_tests/test_run.py src/trio/_util.py- passedFrozenErrorA baseline run of
src/trio/_core/_tests/test_io.pyhad 28 passed and 1 failure because this Windows host emits localized text forWinError 10038while the existing test regex only accepts the English message; this is unrelated to the change.AI assistance was used to investigate, implement, and test this patch. The reported results are from commands actually run on the Windows host.