Skip to content

feat: errors.py#1071

Merged
henryiii merged 4 commits intopypa:mainfrom
henryiii:henryiii/feat/errors
Feb 11, 2026
Merged

feat: errors.py#1071
henryiii merged 4 commits intopypa:mainfrom
henryiii:henryiii/feat/errors

Conversation

@henryiii
Copy link
Contributor

@henryiii henryiii commented Jan 23, 2026

This moves the ExceptionGroup backport into errors.py, and adds an ErrorCollector, based on the one in pyproject-metadata, see here. Pulled out of #847 in support of #1065.

No docs for this module (yet?), and ErrorCollector doesn't have an underscore, but maybe it should, since it's designed for our use. Edit: made it private.

This ErrorCollector doesn't have a toggle to turn off error collection, since it wasn't needed here (and probably not needed for any new API that always raises ExceptionGroups), though maybe it's still handy for debugging?

  • feat: add errors module for ExceptionGroups (move only)
  • feat: add ErrorCollector (All ErrorCollector changes in this commit)

@henryiii henryiii force-pushed the henryiii/feat/errors branch 2 times, most recently from 9981cd4 to 51910f8 Compare January 25, 2026 16:54
Copy link

@sirosen sirosen left a comment

Choose a reason for hiding this comment

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

FWIW, this version of ErrorCollector provides the things I was wanting when I tried it: on_exit() and error() (the inner append() helper).

import sys
import typing

__all__ = ["ErrorCollector", "ExceptionGroup"]
Copy link

Choose a reason for hiding this comment

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

I have a question about __all__, the class names, and the module name:

Is packaging.errors meant to be a public interface? Users presumably may want it to get packaging.errors.ExceptionGroup.

But should ErrorCollector be public? Does it make sense to name it _ErrorCollector to mark it internal to packaging?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No docs for this module (yet?), and ErrorCollector doesn't have an underscore, but maybe it should, since it's designed for our use.

(above)

Yes on the packaging.errors.ExceptionGroup, users need it to handle ExceptionGroup before 3.11.

@henryiii henryiii requested a review from brettcannon February 10, 2026 19:06
Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
@henryiii henryiii force-pushed the henryiii/feat/errors branch from 3278a88 to 0003262 Compare February 11, 2026 01:13
@henryiii henryiii merged commit 77a4f3f into pypa:main Feb 11, 2026
44 checks passed
@henryiii henryiii deleted the henryiii/feat/errors branch February 11, 2026 04:17
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.

3 participants