Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't double-wrap exceptions in nurseries #2826

Merged
merged 8 commits into from
Oct 26, 2023

Conversation

jakkdl
Copy link
Member

@jakkdl jakkdl commented Oct 23, 2023

Fixes #2611

I should probably remove the extraneous tests, and merge it into one of the existing test files, or at the very least rename the test file.

@Zac-HD suggested

"if we're using strict exception groups and the inner nursery raises an exception group with a single exception in it (subtree, not necessarily leaf!) unwrap it concat the tracebacks"

and I suppose that's maybe slightly different behavior from what I implemented?
I added a test case for when the child case itself raises an ExceptionGroup, should the traceback be modified in any way in that case or is it fine to just pass it through?

@jakkdl jakkdl requested review from njsmith and Zac-HD October 23, 2023 14:13
@codecov
Copy link

codecov bot commented Oct 23, 2023

Codecov Report

Merging #2826 (e803320) into master (f85021e) will increase coverage by 0.00%.
Report is 1 commits behind head on master.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2826   +/-   ##
=======================================
  Coverage   99.16%   99.16%           
=======================================
  Files         115      115           
  Lines       17482    17514   +32     
  Branches     3113     3125   +12     
=======================================
+ Hits        17336    17368   +32     
  Misses        101      101           
  Partials       45       45           
Files Coverage Δ
trio/_core/_run.py 100.00% <100.00%> (ø)
trio/_core/_tests/test_run.py 100.00% <100.00%> (ø)

@Zac-HD
Copy link
Member

Zac-HD commented Oct 24, 2023

I think it's fine to pass through.

For the tests, there are currently enough separate cases that I can imagine missing that something is backwards. Could we write something parameterized, such that it obviously does each possible set of operations, and then the asserts only depend on whether we're in strict mode? (I expect this to be harder to read individually, but the confidence in consistency is what I'm after)

Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great to me - the tests still take a moment of thought, but suffice to convince me that it's now correct in general 🎉

The CI failures look like one flake, and one mypy issue to fix - trio/_core/_tests/test_run.py:2563: Missing type parameters for generic type "ExceptionInfo" [type-arg], I think ExceptionInfo[BaseException] would be easiest - and once that's done let's merge!

@A5rocks
Copy link
Contributor

A5rocks commented Oct 25, 2023

Oh just realized this should probably also contain a newsfragment?

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
@jakkdl jakkdl enabled auto-merge (squash) October 26, 2023 12:25
@jakkdl jakkdl merged commit c9e01f4 into python-trio:master Oct 26, 2023
29 of 30 checks passed
@jakkdl
Copy link
Member Author

jakkdl commented Oct 26, 2023

Ah shoot, forgot the newsfragment. Opening a new PR for it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

strict_exception_groups=True "leaks" the implementation-detail nursery in nursery.start(fn)
5 participants