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

Experiment with ExceptionGroup and BaseException.add_note() (in Python 3.11) #3175

Closed
Zac-HD opened this issue Dec 4, 2021 · 1 comment · Fixed by #3308
Closed

Experiment with ExceptionGroup and BaseException.add_note() (in Python 3.11) #3175

Zac-HD opened this issue Dec 4, 2021 · 1 comment · Fixed by #3308
Assignees
Labels
interop how to play nicely with other packages legibility make errors helpful and Hypothesis grokable

Comments

@Zac-HD
Copy link
Member

Zac-HD commented Dec 4, 2021

PEP 654 introduces a new ExceptionGroup type, which is designed to replace Trio's MultiError and our very own MultipleFailures types. There's also neat new except* syntax for handling them, but that's not our problem. Based on our conversation, Irit Katriel also added BaseException.__note__ so that we can attach our Failing example: strings (etc) to the exception objects, instead of printing them by hand.

So before Python 3.11 is released, preferably in the alphas (i.e. before May 2022), we should get this working - preferably shipped; but at least prototyped to a level that any problems can be fixed and re-tested before 3.11rc1.

Presumably at some point there will be a backports.exceptiongroup package that we can standardize on along with Trio, Pytest, and so on; but until then I'm happy to keep using our own exceptions.

@Zac-HD Zac-HD added legibility make errors helpful and Hypothesis grokable interop how to play nicely with other packages labels Dec 4, 2021
@Zac-HD Zac-HD self-assigned this Feb 22, 2022
@Zac-HD
Copy link
Member Author

Zac-HD commented Apr 16, 2022

Since PEP-678 has been accepted and implemented (to be released in 3.11.0b1, in early May) and there's an excellent exceptiongroup backport on PyPI, we'll soon be able to jump directly to using the new approach at all times. Concretely, the plan is to:

Early-draft branch is at master...Zac-HD:use-exceptiongroup, including some notes on use of .add_note().

So we'll have experience with everything early enough that we shouldn't need further patches, and still have the beta period to shake out any problems if they do arise.

@Zac-HD Zac-HD changed the title Experiment with ExceptionGroup and BaseException.__note__ (in Python 3.11) Experiment with ExceptionGroup and BaseException.add_note() (in Python 3.11) Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interop how to play nicely with other packages legibility make errors helpful and Hypothesis grokable
Projects
None yet
1 participant