Skip to content

4.0: FinalizerError as an ExceptionGroup #564

Closed

Description

@lesnik512

This was generated by AI during a pre-4.0 audit of main at 9cd88e7.

Observation

FinalizerError (exceptions/lifecycle.py:6) wraps every finalizer failure in .finalizer_errors, so AsyncFinalizerInSyncCloseError (always wrapped, registries/cache_registry.py:110-120) and user finalizer errors cannot be caught by type. The package requires Python 3.11+, where ExceptionGroup and except* exist. Changing the base class after 4.0 is breaking.

Proposal

Make FinalizerError subclass ExceptionGroup (keep ModernDIError as a base if the MRO allows; otherwise decide). .exceptions replaces .finalizer_errors; is_async stays. Decide whether to keep finalizer_errors as an alias for 4.x or remove it with a migration entry.

Acceptance

  • except* AsyncFinalizerInSyncCloseError and except* ValueError (user finalizer error) work, with tests for sync and async close.
  • except FinalizerError and except ModernDIError still catch it.
  • Docs (lifecycle.md, errors-and-exceptions.md) and migration guide updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestready-for-agentFully specified, ready for an AFK agent

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions