exceptiongroup
Backport of PEP 654 (exception groups)
This package has a good security score with no known vulnerabilities.
Community Reviews
Solid backport for structured exception handling with minimal security surface
From a security perspective, this package is refreshingly minimal. Exception messages and tracebacks behave as you'd expect - no surprises with information leakage beyond what standard Python exceptions already expose. The library doesn't add magic or hidden state. Input validation is inherent to the design: you pass exception objects, and the type system handles the rest.
One gotcha: when migrating code to use exception groups, you need to audit your error handling carefully. Bare `except Exception` clauses won't catch ExceptionGroup by design, which can lead to unhandled exceptions bubbling up if you're not thorough. This is architecturally correct but requires discipline during adoption.
Best for: Projects needing structured concurrent exception handling that want to adopt PEP 654 patterns before upgrading to Python 3.11+.
Avoid if: You're already on Python 3.11+ where ExceptionGroup is built-in, or your error handling patterns are simple enough to not need exception aggregation.
Solid backport for Python 3.10 exception groups with minimal security surface
In practice, it handles exception aggregation cleanly, especially useful when dealing with concurrent operations or validation failures where you want to collect multiple errors before raising. The API mirrors Python 3.11+'s native implementation exactly, making migration smooth. Exception messages are well-formed and don't leak sensitive data by default - you control what goes into each exception.
One practical concern: exception groups can make debugging harder if you're not careful about how you structure error handling. Stack traces become nested, and if you're logging exceptions automatically, ensure your logging framework handles ExceptionGroup properly or you'll get incomplete error reports. The library itself is sound, but teams need to update their error handling patterns accordingly.
Best for: Projects targeting Python <3.11 that need to aggregate multiple exceptions from concurrent operations or complex validation scenarios.
Avoid if: You're already on Python 3.11+ where exception groups are native, or your error handling is simple enough that aggregating exceptions adds unnecessary complexity.
Clean backport with minimal overhead, essential for Python <3.11 exception handling
The API is identical to Python 3.11+'s built-in implementation, which means your code seamlessly transitions when you eventually upgrade. The library handles nested exception groups cleanly, preserving tracebacks properly for debugging. I've used it extensively in async codebases where TaskGroups raise multiple exceptions concurrently, and the error propagation is predictable and observable.
One gotcha: the except* syntax requires special handling pre-3.11, so you'll need to use the .split() and .subgroup() methods directly rather than the syntactic sugar. Documentation could be better on performance characteristics when dealing with deeply nested exception trees, but in practice I haven't hit issues even with hundreds of grouped exceptions.
Best for: Projects targeting Python 3.9-3.10 that need structured concurrent exception handling, especially with asyncio TaskGroups.
Avoid if: You're already on Python 3.11+ where ExceptionGroup is built-in, or you don't need to handle multiple simultaneous exceptions.
Sign in to write a review
Sign In