agronholm / exceptiongroup

Backport of PEP 654 (exception groups)
Other
42 stars 20 forks source link

Add exceptiongroup support to third party projects #23

Open agronholm opened 2 years ago

agronholm commented 2 years ago

As requested on https://github.com/python-trio/trio/pull/2213, we should try to add exceptiongroup support to both IPython and Apport. This issue tracks all efforts to add exceptiongroup support to other projects.

IPython seems to use customized versions of format_exception() and format_exception_only(), so it's likely to need an update to display exception groups, even on Python 3.11.

Apport, on the other hand, uses format_exc() and print_exc() straight from the traceback module, so a conditional import might do the trick.

agronholm commented 2 years ago

As of 1.0.0rc9, other projects can now be made to support exception group formatting via this library.

henryiii commented 2 years ago

Is pytest such a library?

agronholm commented 2 years ago

I believe there are people already working to integrate exception groups to pytest.

renefritze commented 2 years ago

The hypothesis project had a number of PRs concerning the topic.

henryiii commented 2 years ago

The tip:

For now, you can use pytest's --tb=native flag to see the tracebacks for each sub-exception.

looks to be very useful for now. Ideally PyTest will start displaying exception groups and notes natively at some point.

Zac-HD commented 1 year ago

Linking all the ecosystem issues and status I know of, so they're visible in one place:

jakkdl commented 1 year ago

@agronholm are you okay with adding/moving the apport excepthook we currently have in Trio over to exceptiongroup? I can report a bug and open PR in apport for adding exceptiongroup support, but as Zac above says exceptiongroup would also need to carry a workaround due to Ubuntu being very conservative in package versions and new apport releases would take approximately forever to trickle down to all end users.

agronholm commented 1 year ago

I'm okay with it as a workaround, so long as it doesn't affect anything else.

jakkdl commented 1 year ago

Apport looks like we'd report a bug to https://bugs.launchpad.net/apport and open a PR at https://github.com/canonical/apport; see https://github.com/python-trio/trio/issues/2464 for links to Trio's current workaround

As of #88 there is now a workaround for apport, but I also opened https://bugs.launchpad.net/apport/+bug/2042672