On Tue, Feb 23, 2021 at 3:49 PM Damian Shaw <damian.peter.s...@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
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/TWEGKU7H5GC3I4WHNVBQ2EPWQMSP633Q/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to