-
-
Notifications
You must be signed in to change notification settings - Fork 335
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
change strict_exception_groups default to True #2886
Changes from 13 commits
cfc0755
84fb527
c4548bd
2437d1e
dcadc87
a39732f
669c345
f7e0b8f
38f47a5
d455a45
4232be2
5caf49f
f50386c
5acae48
a33bea6
295e5af
0089248
26a9c62
a93a185
b3d5aa3
c00a05f
4b393ed
e64d508
0547313
22e4765
79754b8
506e211
ea48cf0
3f519f8
0b45ec9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
``strict_exception_groups`` now defaults to True in ``trio.run`` and ``trio.start_guest_run``, as well as ``trio.open_nursery`` as a result of that. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As as result of that what? I'd also use rst cross-references here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. kinda awkward wording, but should be better now |
||
This is unfortunately very tricky to change with a deprecation period, as raising a ``DeprecationWarning`` whenever ``strict_exception_groups`` is not specified would raise a lot of unnecessary warnings. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -937,7 +937,7 @@ class NurseryManager: | |
|
||
""" | ||
|
||
strict_exception_groups: bool = attr.ib(default=False) | ||
strict_exception_groups: bool = attr.ib(default=True) | ||
|
||
@enable_ki_protection | ||
async def __aenter__(self) -> Nursery: | ||
|
@@ -1005,8 +1005,8 @@ def open_nursery( | |
|
||
Args: | ||
strict_exception_groups (bool): If true, even a single raised exception will be | ||
wrapped in an exception group. This will eventually become the default | ||
behavior. If not specified, uses the value passed to :func:`run`. | ||
wrapped in an exception group. If not specified, uses the value passed to | ||
:func:`run`, which defaults to true. | ||
|
||
""" | ||
if strict_exception_groups is None: | ||
|
@@ -2171,7 +2171,7 @@ def run( | |
clock: Clock | None = None, | ||
instruments: Sequence[Instrument] = (), | ||
restrict_keyboard_interrupt_to_checkpoints: bool = False, | ||
strict_exception_groups: bool = False, | ||
strict_exception_groups: bool = True, | ||
) -> RetT: | ||
"""Run a Trio-flavored async function, and return the result. | ||
|
||
|
@@ -2228,9 +2228,9 @@ def run( | |
main thread (this is a Python limitation), or if you use | ||
:func:`open_signal_receiver` to catch SIGINT. | ||
|
||
strict_exception_groups (bool): If true, nurseries will always wrap even a single | ||
raised exception in an exception group. This can be overridden on the level of | ||
individual nurseries. This will eventually become the default behavior. | ||
strict_exception_groups (bool): Unless set to false, nurseries will always wrap | ||
even a single raised exception in an exception group. This can be overridden | ||
on the level of individual nurseries. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer this to the phrasing in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's important to add that " There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to add a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added note about |
||
|
||
Returns: | ||
Whatever ``async_fn`` returns. | ||
|
@@ -2288,7 +2288,7 @@ def start_guest_run( | |
clock: Clock | None = None, | ||
instruments: Sequence[Instrument] = (), | ||
restrict_keyboard_interrupt_to_checkpoints: bool = False, | ||
strict_exception_groups: bool = False, | ||
strict_exception_groups: bool = True, | ||
) -> None: | ||
"""Start a "guest" run of Trio on top of some other "host" event loop. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not thrilled about either wording (proposed or original) though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we'll eventually want to rewrite this whole section from the new strict-by-default perspective, under the heading "Deprecated: non-strict
ExceptionGroup
s" - to explain that it only exists for backwards-compatibility, will be removed in future, and that we recommend against it for all new code.I don't want to delay this PR further though, so let's open an issue to revisit the docs on this topic rather than waiting to merge.