On Tue, Feb 23, 2021 at 3:49 PM Damian Shaw <damian.peter.shaw@gmail.com> wrote:

Firstly, if I have a library which supports multiple versions of Python and I need to catch all standard exceptions, what is considered the best practise after this PEP is introduced?

Currently I might have code like this right now:
try:
    ... # Code
except Exception as e:
    ... # Logic to handle exception


Hi Damian, 

Catching all exceptions in this way is not a common pattern. Typically you have an idea what kind of exceptions you expect to get from an operation, and which of those exceptions you are interested in handling. Most of your try/except blocks will be targeted, like handling KeyError from d[k], an operation that will never raise an ExceptionGroup.

ExceptionGroups will only be raised by specific APIs which will advertise themselves as such. We don't expect that there will be a need for blanket migrations of "except T" to "except (T, ExceptionGroup)" to "except *T".

Irit