-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-99553: add tests for ExceptionGroup wrapping #99615
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
Changes from 2 commits
4b9e01a
29b9f27
07bdfea
9bdb9c6
774b0b8
043d002
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 |
---|---|---|
|
@@ -965,9 +965,10 @@ their subgroups based on the types of the contained exceptions. | |
def derive(self, excs): | ||
return Errors(excs, self.exit_code) | ||
|
||
Like :exc:`ExceptionGroup`, any subclass of :exc:`BaseExceptionGroup` which | ||
is also a subclass of :exc:`Exception` can only wrap instances of | ||
:exc:`Exception`. | ||
A subclass of :exc:`BaseExceptionGroup` that extends :exc:`Exception` | ||
cannot wrap :exc:`BaseException`\ s, as is the case with :exc:`ExceptionGroup`. | ||
However, there is no further restriction: a :exc:`BaseExceptionGroup` subclass | ||
which extends :exc:`KeyError` could wrap any :exc:`Exception`. | ||
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 this is a strange thing to say in a doc, because why would you expect it to not wrap any Exception? Maybe instead of the second sentence we could just explain the motivation for the restriction: “This ensures that wrapped BaseExceptions are not caught by ‘except Exception’.” 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.
Suppose we have However this logic is not applied consistently: if (I'm not trying to reopen the design discussion, just trying to explain my perspective) 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. Ok, I see. Well yes, the Exception case is different - people use ‘expect Exception’ as ‘catch everything except fatal errors’. |
||
|
||
.. versionadded:: 3.11 | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.