On 31 May 2018 at 14:47, Danilo J. S. Bellini <danilo.bell...@gmail.com>
wrote:

> The idea is to allow catching exceptions beyond checking their MRO,
> using a class that checks the exception instance by implementing
> a custom __instancecheck__.
>

The exception machinery deliberately attempts to avoid instantiating
exception objects whenever it can, but that gets significantly more
difficult if we always need to create the instance before we can decide
whether or not the raised exception matches the given exception handler
criteria.

So quite aside from any philosophy-of-design questions, we're unlikely to
ever implement this simply for laziness-of-evaluation reasons. (There are
already lots of circumstances that force instantiation - that doesn't mean
we're keen to add more)

Cheers,
Nick.

P.S. There's a somewhat related issue aimed at getting ABCs to work
correctly as exception handlers, although that still sticks to the
principle that exception handler checks solely consider the exception type,
not its value: https://bugs.python.org/issue12029

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to